How can I access the UINavigationController from the AppDelegate class in a UITabBarController application?
Like when I'm in a section within the UITabBarController item, I can do self.navigationController.
However, that doesn't exist in the AppDelegate.
Thank you,
Tee
There's no correspondence between navigation controller and app delegate the way there is between navigation controller and the view controllers under it. If your app delegate sets up the navigation controller for a given tab item, it can certainly keep a reference to it in a property or ivar, but you'll need to manage that yourself.
Related
Let's say you have an application in which you know for sure that there's always a UINavigationController displayed, and that I need to display another view controller modally from outside this controller (for example : because I use the Command pattern and I don't want to give a reference to a view controller to it).
Is there a safe way to get the "root" navigation controller, and call its presentModalViewController:animated method ?
I tried to use [UIApplication sharedApplication].keyWindow.rootViewController but I figured out that it was nil during an alert.
Are you using a storyboard or separate xibs?
If you're using separate xibs then you will be setting up the UINavigationController in applicationDidFinishLaunching.
You can make the navigation controller a property of the app delegate.
Then you can access the UINavigationController from anywhere by getting the singleton app delegate and getting the navigation controller property from it.
Okay I have a well known problem. I want to implement a tableview controller into a navigation controller. And this navigation controller should be implemented in a tabbar controller.
I am using XCode 4.2 and I started a new project with a tabbar controller template
Now what I did was in the xib file from firstViewController deleted the view and added a navigation controller with a tableview controller in it.
I connected the files owner view to the tableview item. But when I build and run it only shows the table view and not the navigation controller.
Can anybody help?
Kind regards
There is the TabBarController Application. In this application you will see how to implement NavigationController and TableView together in the TabBarController application:
http://www.edumobile.org/iphone/iphone-programming-tutorials/tabbarcontroller-with-navigationcontroller-and-tableview-in-iphone/
What are the best practices to connect master tableView to a detail view(a tabBarViewController)?
Also in my case when ever i select a row all the viewControllers inside the tabar should refresh/reload.
Just delegate tableView methods in your tabBarViewController. Write <UITableViewDelegate> in your interface declaration.
I want to combine UITableViewController and UITabBarController:
1) UITableViewController with navigation is shown
2) UITabBarController is pushed
([self.navigationController pushViewController:nextController animated:YES];),
the tabbar is shown, navigationItem is invisible, but the navigationBar stays.
Is this possible? Is there an example?
Correct me if I'm wrong, but it sounds like you have a UINavigationController with a UITableViewController pushed onto it and you would like to push a UITabBarController on to the navigation stack as well. If that is the case, then you may want to read Apple's View Controller Programming Guide for iOS where is states the following:
"Although a navigation controller can be embedded inside a tab, the reverse is not true. Presenting a tab bar interface from within a navigation interface is potentially confusing for users."
Having written that, there is a way to do it, but you must use a custom UIViewController instead of a UITabBarController. This is discussed in detail here
In a Navigation-based application, the method pushViewController:animated can be used. This is a method of the UINavigationController class. However, nowhere in the source files do I see any #import statements that import this class. The documentation doesn't show UIViewController as inheriting from UINavigationController.
So how are Navigation-based applications able to access this method?
UIViewController has a property called navigationController which is an instance of a UINavigationController. This is how it gets access to it.