My navigation controller not working.
I take a tabbar-based application now from app delegate. I want to add a navigationcontroller but it's not working.
[window addSubview:navigationController.view];
I simply make an object of uinavigation controller and synthesize it.
Actually you don't need to add navigation Controller's view in the window, if you want to add a navigation controller in tabbar controller application.
See the below screen shot, you just need to select the tabbarcontroller in the IB and then from inspector window you can select class or particular tab item. Just make then navigation controller.
Open MainWindow.xib.
Under TabBarController you will see two view controllers.
Delete both of the view controllers.
Now, from the library add two navigation controllers under TabBatController.
Now, open the inspector of the navigation controller and set its nib name and the class name.
i think this will solve your problem.
You can also go through
http://21gingerman.wordpress.com/2009/04/06/tutorial-and-sample-code-for-iphone-app-with-tab-bar-and-nav-bar/
Related
I have the following hierarchy in my app: UITabBarController to many UINavigationControllers. Each navigation controller has a UIViewController.
I’ve split this up so that each UITabBarController’s child view controller is linked via a storyboard reference. In each of these references there’s a UINavigationController as the initial view controller.
Again some of these other storyboard references are split up too, where one of the UINavigationController’s child view controllers also uses a storyboard reference.
These UINavigationController’s child view controllers in the new storyboards do not carry across the UINavigationController style. Unlike the UITabBarController which does take across the UITabBarItem and shows them in the UINavigationController.
Is there anything I can do to see the navigation item of these UINavigationControllers so I can add bar button items in IB?
It's straight forward really; just go to Editor > Embed In > Navigation Controller and embed your view controller in a UINavigationController. You can then select the UIBarButton items under the Object Library in xCode, drag and drop them to the navigation bar on your View Controller and voila!
You can then delete the UINavigationController when done with adding the UIBarButton items to your VC; those bar button items will still be referenced and shown in the final product when you run it.
In Storyboard go to the Attributes Inspector for the Controller you wish to add the navigation bar and click on top bar drop down instead of it saying 'inferred' click on 'Translucent Navigation Bar'
The Problem
I'm relatively new to Swift and I'm trying to build an application that makes use of a UITabBarController.
What I'm trying to do is put a different navigation bar (or UINavigationItem) on each of the tabs in the UITabBarController.
For example, I want the UINavigationItem I set, with its bar button items, to appear on MyViewController instead of a back button to the previous view controller, such as shown on the image below.
The current layout on the Storyboard is as follows.
MyViewController on the sidebar:
What I've Tried
Someone suggested that I should embed each UIViewController (e.g. MyViewController) in a Navigation Controller. I've tried this and it doesn't work.
I've also tried to set the Top Bar to "None" in the Attributes tab of the options menu.
Thank you in advance for your help.
Here is how i did it,
UINavigationController -> UITabbarController
And then each "Tab" is in different Storyboard and every storyboard start with a "Navigation Controller". So yes every tab in different navigation controller this how you should do it.
Different storyboards because may be multiple people work on storyboard at same time.
Why TabbarController inside Navigationcontroller ?
I put the "TabbarController" inside "NavigationController" because some of the controllers i want them to be full screen, like hiding the "Tabbar" so for that i push them from main NavigationController.
//Out of context but may help you,
I have created an "Extension" of Navigation Controller to push a view controller on main navigation so that any of the tabbars (which are also inside navigation controllers) can easily use the extension to push any view controller if want to hide the tabbar.
Hi I've a problem I tried to solve it by reading the docs but I couldn't.
I want to the tab bar controller to be the initial VC Not the SWRevealViewController.
The issue is that the slide out menu in side the app not the first vc.
So the question how to make the SWRC there?
Why could not you move your reveal view controller as a last controller in navigation queue and use your controller with "Item" menu as Sw_front? It should work.
As an alternative you can remove the whole reveal view controller from Storyboard and create it manually from your first view controller in navigation queue. And then push.
SWRevealViewController has a method called initWithRearViewController:frontViewController, and you can obtain Sw_rear and Sw_front view controllers with instantiateViewControllerWithIdentifier from Storyboard.
Then, when adding Item menu (manually) to navigation bar, you assign revealToggle: as action and your SWRevealViewController instance as target.
There are some variations of this approach, you can place your SWRevealViewController before the Navigation Controller in Storyboard and specify Navigation Controller as a Sw_front. Then you do not need to instantiate SWRevealViewController manually, but only "Item" menu.
Here could be also useful to removeGestureRecognizers from reveal view controller on viewWillAppearof intermediate view controller in navigation queue and then add back panGestureRecognizer and tapGestureRecognizer on viewWillAppear of the view controller with "Item" menu.
UPDATE
Here is the sample project of using SWRevealViewController in Swift with Tabbar.
I've just taken the sample project from http://www.appcoda.com/sidebar-menu-swift/ and adjusted a little bit.
And what I dislike about using SWRevealViewController with Storyboards is that each new ViewController to be shown, has its own Navigation Controller, but if it works for you, you can keep it.
My app has a menu and a UITabBarController. What I want to do is to display a view controller that belongs to my menu but not to the UITabBarController, However I don't want to remove the UITabBarController. I tried codes similar to the one below but they are removing the UITabBarController.
tabBarViewController.selectedViewController?.presentViewController(ExtraViewController, animated: true, completion: nil)
You should get UINavigationController of selected ViewController and then push view you want to present. Otherwise you are presenting modal view controller with presentViewController witch hides your UITabBarController view.
Im not at my computer right now, and cant post any code, but hope this helps.
Best way to do it is to use UINavigationController. You can create new one programmatically and put your menu controller as root.
And if you put this UINavigationController as one of views in UITabBarController then you can preform a code like:
[self.navigationController pushViewController:ExtraViewController animated:NO];
Also you can use storyboard to create your controllers hierarchy like that:
To do that select your menu controller and go to Xcode menu>Editor>Embed in>Navigation Controller and then Xcode menu>Editor>Embed in>Tab Bar Controller.
I have a hierarchy of 3 TableViewControllers embeded in Navigation Controller and I need to launch on the most detailed level on the top of the hierarchy. If I change 'Is Initial View Controller' in storyboard to the last detailed TableViewController, my app launches with the selected TVC, but with no NavigationBar. How can I launch on the desired level of hierarchy and keep the Navigation Controller managing the stack of views?
Thank you.
You're telling the storyboard that your third view controller is the root view controller--it has no navigation bar. If you want the navigation controller present as the root view controller then you need to make it the initial view controller, then change the navigation's root to your third view controller.
eg:
initial-->[navigation controller]-->[third VC] [first VC]-->[second VC] (keep these around if you want... just disconnect them from the navigation controller)
You would have to select the ViewController that you want as initial and embed it into a NavigationController, and then add all of the other views after that using push segues.
But why do that? Why not just have the first viewcontroller display the data that you will have in the third view controller? you will end up with the same results.
You should also check out this.