MPMediapickercontroller tab bar overlap with custom tab bar in iPhone - iphone

I can hide or unhide tab bar in navigation controller. But issue when I use presentModelViewController of MPMediapickercontroller, and even when hiding custom tab bar, it overlaps the tab bar of MPMediapickercontroller.
Please take a look at this image.
This is a default 'MPMediapickercontroller' presented.
I have been surfing to find this fix but with no success.

In MPMediapickercontroller its always present modally. so one solution for that is you have to use image which is same as tabbar of MPMediapickercontroller.
Here is that image. use without any border just white image thats it.
Now, below is my code.
In Viewwillappear method you have to set that image in tabbar appearance.
-(void)viewWillAppear:(BOOL)animated
{
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tabDefault"]];
[super viewWillAppear:YES];
}
Then whatever you want presentModelViewController of MPMediapickercontroller
in last you done all things then you have to use dealloc method to set Tabbar same as you required permanent.
-(void)dealloc
{
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tab2"]];
}
I solved my problem from this. hope you done it.

Related

appearanceWhenContainedIn not working as expected

I'm using iOS's UIAppearanceProxy to customize the look of my app.
In most of the app, I want the navBar to have one background image. In one specific section of the app, I want the navBar to have a different background image.
Here's what I'm doing in application:didFinishLaunchingWithOptions:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navbar_bg1"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearanceWhenContainedIn:[DiscoverViewController class], nil] setBackgroundImage:[UIImage imageNamed:#"navbar_bg2"] forBarMetrics:UIBarMetricsDefault];
I would like to keep all my appearance code in one place instead of overriding the navBar in a specific view controller.
Also helpful to know is that my app is structured with a TabBarController, where each tab controls a NavigationController which owns a subclassed ViewController, like DiscoverViewController above.
What am I doing wrong?
As you just stated, the navigation bar is not contained in the DiscoverViewController in your hierarchy; rather, both are contained in a navigation controller. One way to keep the appearance code centralized is to create an empty subclass of UINavigationController and instantiate that instead of UINavigationController in the relevant place (whether that's a nib or storyboard or just programmatically). Then, to style child elements, get their appearance proxy "when contained in" DiscoveryNavigationController or what have you. I've used this method with good results in the past.

How to remove or clear a Tabbar image in iphone?

Currently, I am working in simple iPhone application, using Tabbar to create three option and set three images in each view controller, then I click second tabbar show the viewcontroller2 and navigate to another screen, at the time i want to clear or remove tabbar image from this screen, But I can't fix this, please help me.
Thanks in Advance
I tried this:
[[UITabBar appearance] setAlpha:0.5];
Use this to solve it:
UITabBarItem *filterTab = [self.tabBarController.tabBar.items objectAtIndex:3];
[filterTab setImage:[UIImage imageNamed:#""]];
You can also pass a nil value for the setImage property. Like: [filterTab setImage:nil];
Do this at the point you want to hide the tab bar view. (maybe in viewWillAppear in the other screen you navigate to from viewcontroller2.
[self.tabbarcontroller.tabbar setHidden:YES]
It can be possible if you do
presentModalViewController
on UIWindow
I think, this will solve your issue
Hope it helps you....

UIBarButtonItem tintColor with UINavigationController

I have a navigation controller with 2 UIBarButtonItems in my navigation bar. I want to change the tint color only for the one on the right. I have found a way in static to do that:
[[self.navigationController.navigationBar.subviews objectAtIndex:2] setTintColor:[UIColor redColor]];
The problem is when I push a controller into my navigation controller to display another view, when I come back to the root view where my right navigation bar button is supposed to have a custom color, the color of the button is back to its default. And when I click again on it, the app crashes. It says it cannot change the tint color, like if the index for this element in my navigation bar changed.
I have tried other technics found on the internet, but they all failed when I use the navigation controller and come back to the root controller...
Any idea?
Thanks!
Edit 1:
I would like a bordered style button in my UINavigationBar, with a red or green background color.
Regarding the other ways I found, it is pretty much a foreach loop of the views in the navigation bar, and if the view's kind of class is a button item then change the tintColor. It doesn't crash but it applies to all the UIBarButtonItem of my navigation bar (and I just want a specific button, the right one, not all of them). For example this tutorial is half working, my app crashes when coming back to the root view controller.
Digging into the subviews of the navigationcontroller.navigation bar wont fly with Apple, ...
the correct way to change the color of a UIBarButtonItem is to use a customView with the buttonitem. here is a link that explains...
UIBarButtonItem with color?
You simply create a segmented control with just one segment. Set its tint color as you like. You may also want to set its mode to momentary so it optically behaves like a button. Add the segmented control to the bar button item by using the initWithCustomView: initializer. That's how you typically create custom tinted buttons.
Example:
UISegmentedControl *cartControl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(10,7,60,30)];
[cartControl setTintColor:[UIColor colorWithRed:0.35 green:0.47 blue:0.65 alpha:1]];
[cartControl addTarget:self action:#selector(cart:) forControlEvents:UIControlEventValueChanged];
[cartControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[cartControl insertSegmentWithImage:[UIImage imageNamed:#"shopping_cart_white_small.png"] atIndex:0 animated:NO];
[cartControl setMomentary:YES];
UIBarButtonItem *cartButton = [[UIBarButtonItem alloc] initWithCustomView:cartControl];
[cartControl release];
[[self navigationItem] setRightBarButtonItem:cartButton];
[cartButton release];

where are my UIBarButtonItem & UIToolbar on UIPopoverController

I have an iphone app, on the top of screen there is an UIToolbar, there are 2 UIBarButtonItem on the UIToolbar.
One is 'Cancel' another is 'Confirm'.
But if I migrate the project to ipad and present the view/ViewController using UIPopoverController, these two UIBarButtonItem & UIToolbar disappear.
I know if I touch anywhere outside the UIPopoverController, it will disappear, but I prefer to keep the UIBarButtonItems to ask for confirmation of some option.
Is it possible?
Welcome any comment
Thanks
The popoverController does not dissapear by itself when you click outsite. The code that makes it dissapear is:
if([self.popoverController isPopoverVisible])
{
[self.popoverController dismissPopoverAnimated:YES];
return;
}
Make sure you have added the UIToolbar to the viewcontroller's view before presenting it in the popover.

How to prevent view resizing/transform when UINavigationBar hides/shows

I have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)