TabBarController in NavigationController does not show TabBar in viewControllers - ios

I have a UITabBarController to whose controllers I would like to attach navigation. So I inserted the NavigationController as the entry controller, and the tabBarController as its root. All seems working fine, but for the tabBar. Basically it does not show, albeit the StoryBoard I attach seems to say differently. I also attach the Account Screen not showing any navigation bar nor, of course, any back button.
Thanks,
Fabrizio

Just a quick answer. I think you should put UINavigationController inside the TabBarController instead of the other way round. It will solve most of your problems.
Steps: Editor -> Embed in -> Navigation Controller
See the below screen shot on how to add a Navigation Controller to a View Controller.

You are following wrong approach, IOS does not allow you to use tabbarview controller as root of navigation controller, it always display black screen. I have faced same problem and as a solution i have added navigation bar after tabbar controller. Yes it becomes difficult to manage, but you can use that way and it will work.
If you use programmatic approach instead of storyboard then it is possible, see this link
Even you can try from Editor option of XCODE, select tabbar controller you have added from storyboad then go to Editor->Embedded in, you will see that navigation bar controller is disable.
This is also give you idea that it will not work.

Related

Using UITabBarController with UINavigationController - Swift 3

I am making an app which requires a use of a UITabBarController along with UINavigationController. I have made the following flow in storyboard.
See image
Now the first question is that is this accepted by Apple, as there are too many discussions for the same.
The other matter of concern is that is it possible to eliminate any UINavigationController and still get the same flow of the app? The main thing required is to have the SAME tab bar and navigation bar on all sub tabs of the tabs. One point to be noted is that if I remove the second UINavigationController then my app navigates directly from sub tab to home view controller on clicking back button.
I have been stuck on this since hours now. I am new to iOS app development and have never uploaded any app to the app store. Any help would greatly valued.
EDIT :
I put the second navigation controller as shown in the answers - see this flow, But because I have a navigation controller before the HomeViewController, so I am getting a navigation bar at the top and then some empty space below that(exactly equal to the top navigation bar) and then the page contents on runtime. Any solution to this?
Yes, it is acceptable by Apple.
But View hierarchy is not managed correctly. In your case Tab bar will be the root view controller for 2nd navigation controller.
Also, Tab and sub tab you are pushing will be part of 2nd navigation controller.
That's the reason you are getting back on Home view controller.
It's good practice to keep navigation controller to each Tab to manage it's sub-tab hierarchy.
You could present tab bar controller or setviewcontroller from Home View controller.
First embed tab bar controller as in this image and the embed navigation bar controller as in this image finally this will look like

Xcode simulator - Navigation bar is missing

I don't know why but my navigation bar is missing from my ios simulation.
Anybody know where might be the problem?
Yes I have "Shows Navigation bar" and I don't have any warnings.
I wanted to try "Update frames" but I don't have this option available.
I am using Xcode 7.3 and Swift.
Thank you
You can solve by embedding a navigation controller:
As other people have said in the comments without showing some code or screenshot of IB it's hard to find out where the problem is... But here's some things to checkout.
Are you sure your view controller is embedded in a UINavigationController?
If you are using Storyboards you should have something like this:
In code instead you might have set the window.rootViewController property in the AppDelegate to the content view controller rather than the navigation controller which is supposed to contain it.
Its depend how to embedding navigation controller but you can try to embedding navigation controller following below way and than run application and check in simulator : Go to Editor in xcode -> Embed in -> Navigation Controller.
I had the same problem: the navigation bar was showing on the root view in Storyboard, but when running the Simulator - there was no navigation bar at the top of the views. This solved it:
Navigation Controller > Navigation Bar > UNCHECK Translucent (it is checked by default). This did two things:
My Navigation Bar shows on all subsequent views.
The topmost subview on subsequent views is now at Y=0, and not Y=64.
There are two possibilities.
1) May be you didn't Embeded navigationcontroller before your viewcontroller. so, add Navigation controller with go to
Editor -> Embededin -> Navigation controller.
2) If you have add navigation controller but May be you have set NONE as topbar of Viewcontroller.

Tab bar controller is not showing bar button item

I'm new in Objective-C, and even more using storyboards. This being said I'm trying to use a bar button item within UITabBarController and UINavigationController as can you see in the image below.
But once I run the project in simulator this item is not showing. I would appreciate a non programmatically solution if it's posible.
Okay, so the way to do this:
When you create your tab view controller. You have to add a navigation controller that will handle each tab.
Tab View Controller --> navigation controller --> View Controller 1.
Then add the bar button item to view controller 1. Then go ahead and add the segues.
Now, still it won't show up.
But, if you go to your code for your view controller 1: Add a reference from the storyboard of your bar button item into your View Controller 1 file. Then, in ViewWillAppear():
self.tabBarController.navigationItem.rightBarButtonItem = _btnNewContact;
From there, it will show up and the segue you have configured in your storyboard should work perfectly! =)
After I spent a while trying to get the best way to do it I finally did that I should have done since begin. Read official apple documentation.
Parameters
viewController
The view controller that is pushed onto the stack. This object cannot be an instance of tab bar controller and it must not already be on the stack.
In other words, my approach is just a bad design.

Showing UINavigationBar not working

I have a UITabBarController inside of a UINavigationController which originally had the navbar hidden before the view when the tabs were needed, though when I try to show the navbar inside the file nothing happens and if I do it just before the transition then it appears before I have pushed between the two controllers is there a way to stop this effect and make it so that when the next ViewController loads the navbar is on it when it appears?
This is not an OS specific issue as it occurs in iOS 6 and 7
The UITabBarController class is not designed to be used as a child of a UINavigationController, which might explain why you're seeing odd behaviour. If you absolutely need a tab bar within a UINavigationController, you'll probably have to roll your own. Otherwise, make your UITabBarController the window's root view controller and populate it with navigation controllers.
Managed to work it out though gave conmulligan the credit because he gave me the idea which was to keep the navigation bar hidden and to embed the viewcontroller inside a new navigationcontroller so there was a whole new navbar

ios - UITabViewController working, but now my other segueys stopped working

I enabled o UITabView on the bottom of the screen, and that works, but the rest of my buttons on the app screen suddenly stopped working. Would anyone know why that might happen? I was using push segueys for them.
I think the issue may be that originally I have a NavigationController that I use on the app, and then the UITabBar controller interferes with it.
Thanks!
As per Apple recommendation, UITabBarController should only be the root controller of an app. I think what you are doing is you are having the UITabBarController nested in your UINavigationController, and that won't work.
You can instead select your navigation controller and embed it in a UITabBarController. (I don't have XCode with me now, but I think there's an option in the menu called Embed in -> Tab Bar Controller. You can search for it in Help.)
(If you need the tab bar controller to be nested under nav controller, I believe you need to use some buttons to fake its effect.)
If you only need a tab bar but not tabbar controller, then don't use tabbar controller.

Resources