iPhone: Translucent navigation bar inside a UITabBarController - iphone

Here it is.
I have a UINavigationController inside a UITabBarController.
Is there a way to set the navigation bar translucent??
I tried, programmatically, to set it like this:
navigationController.navigationBar.translucent = YES;
but nothing changes.
I even tried to log the translucent value and it is actually YES but the bar is still completely opaque.
The view behind the nav bar covers the full screen, i can even see it under the (translucent) status bar. I really don't understand.
All this happens only if the nav controller is inside the tabbar controller.
EDIT:
Guess what? It was xcode screwing up my nib file ...
I recreated the xib from scratch and it works as expected.
Thanks anyway

You are setting the wrong property:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

I am also trying to change navigation bar style for my UITabBarController based app recently using XCode 4.2.1. The code given by Zebs is wrong in this context. If you are working with navigationController that you create by yourself, then it'd be ok, but the thing is, the navigationController created by the UITabBarController is created by UITabBarController hence the correct code is:
self.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
Note we use moreNavigationController instead of just navigationController. Hope that helps everyone who is facing the same problem.

Related

iPhone: I can't change the color of my UINavigationBar

I can't change the color of my UINavigationBar.
I've put a navigation bar manually using Interface Builder, but I can't change its color to the following settings. I'm putting this code on ViewDidLoad (the code works fine with other classes on my app, except this one, where I'm using the UINavigationBar via IB):
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.122 green:0.467 blue:0.255 alpha:1.00];
Any suggestions? Thank you!
Did you check that you have the navigation bar connected through IB? as in, Did you declare a IBOutlet UINavigationBar in your controller, and then connected the navigation bar in IB to it's outlet?
You might not be on the navigation controller stack at this point. Trying putting it in viewWillAppear:
EDIT: You can check this by seeing if self.navigationController.navigationBar returns nil.

Getting empty view and blank navigation bar when I use popViewControllerAnimated

I'm writing an iPhone app that is based on a UINavigationController. I'm pulling data from a server that sometime returns bogus links. I open each link by pushing a webview viewcontroller. I want to be able to include some error handling. I know if the link is no good. So I want to be able to pop the webview view controller as soon as I know that my webview has encountered an error.
Currently, I've tried using the following code:
[self.navigationController popViewControllerAnimated:YES];
I then get a Navigation bar with nothing displayed in it, but if I click where the "back" button should be it operates appropriately. The title pops up when I click where the "back" button should be. The view where the viewcontrollers usually display there content is blank white too even though I'm popping back to a UITableViewController.
I've tried this as a workaround:
UINavigationController *nav = self.navigationController;
[self.navigationController popViewControllerAnimated:YES];
[nav.visibleViewController.view setNeedsDisplay];
I've checked the viewControllers array in the UINavigationController and it has the right viewcontrollers in it (ie it has removed the viewcontroller for the webview).
I also tried putting code in the viewWillAppear of the viewcontroller I'm popping back to, but the method is never getting called.
I'm looking for a way to force the UINavigationController to reload the same way that you can call reloadData on a UITableView.
Any help would be greatly appreciated.
I saw something like this on my app where I was using a navigation bar I added in Interface Builder on the root view of a navigation controller and then programmatically creating the nav bar and its subviews for the second view. When I would pop the second view to return to the first view I would hide the self.navigationcontroller bar which would show the white space underneath until the IB nav bar of the previous view appeared. To fix this I decided to stick with programmatically creating all my navbars which fixed the issue for me.
TL;DR - if you are using both IB and programmatically made navbars this can happen when popping views, stick with one or the other for all the navbars yo

Hiding Tabbar still occupy Space?

I am creating a navigation base application. I need to display a tab bar too.
My mainWindow.xib contains:
UINavigationController,
UITabBarController.
UITabBarController has three UINavigationController with it.
On a condition-based algorithm, I am displaying the Navigation and the TabBar.
It's working well. The problem occurs when I want to move any inner view of TabBar: it shows navigationBar there (what I need) but it shows TabBar too. I want to remove the TabBar of all inner view. When I hide the tabbar it still occupy its space at the bottom of view. I had tried to reset frame of View and Window but nothing helped.
How can I hide tabBar and use its space in my view?
Is the logic I am using correct or not? If not, please tell how to correct it. If there is a tutorial it would be better.
You can try this:
yourInnerViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:yourInnerViewController animated:YES];
The answer is that you can't and trying to force it will break apple's HIG and they'll most probably reject your app.
The way I got around it was to use [self presentModalViewController:animated:] instead of [self.navigationController pushViewController:animated:].
I know its annoying, but a tab bar controller is there to switch between sections of your app. Therefore it provides functionality outside of the context of the navigation controllers within it and therefore cannot be hidden (properly) from inside one of those navigation controllers.

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)

Resizing viewControllers view that are part of a UINavigationController on IPhone

I am using a UINavigationController to handle the pushing and poping of viewControllers in my app. Theres a section where i have a tab bar (not using UITabbarController) which is manageed by the same UINavigationController, i simply add the UITabBar to the navigation controllers view (by using addSubview).
The Problem:
I have some UIViewControllers with table views being pushed into the navigation stack, since my Tab Bar is part of the view and not the navigation stack the TableViews are cut off at the buttom because the Navigation Controller does not know of the tab bar because its in its view and n ot the navigation stack. Without a navigation controller i would just resize the ViewControllers view and it would work fine, but when i try to do that it seems like the NavigationCOntroller just ignores my frame and sets its own and therefore the table views are cut off. I found one solution which was to add some extra cells and hide them and that works sort of OK but its kind of hackerish, anyone have any suggestion of how to go about this in a different non -hackerish way?
Thanks
Alright, so i solved the problem. I had tried resizing the UITableView instead of the viewController before, but this did not work. I just realized though, that this did not work because i was using a UITableViewController which manages its own tableView and was not letting me change the frame of it (maybe i was changing it in the wrong place, tried in viewDidLoad, i bet if i did it after the call to [super viewDidload] it would have worked..o well). So I changed the class to a UIViewController and managed the table view in there, now it works good, thanks for the replies.
Try making the root view a UIView with a UITableView for a subview. Then add the UITabBar to the UIView instance. Now the UITableView won't know about the UINavigationController.