So I have a Navigation Controller in which for every row select, I push ViewController A. However, ViewController A is another table of items.
So I'm having trouble figuring out how to make ViewController A also act as a navigation controller, in which for ever row I select in ViewController A, I can push a view controller, which, we'll name ViewController B.
I tried to add a Navigation Controller object inside an existing Navigation Controller to no avail.
How will I go about this?
Thanks in advance!
NavigationController has a rootController - in your case this is a some kind of table view controller. When you push view controller A - you use parent Navigation Controller. So you can push as many as you need view controllers via this "parent" navigation controller. Read carefully this section of apple docs
Related
There are A,B and C-View Controller.From A view controller, I used navigation push syntax to move to B.From B View Controller I used the same syntax to move to C.So that B becomes parent of C.Now I have to remove B View Controller from the stack.Can anyone suggest how to remove Parent View.When I press back button the page should redirect to A view controller From C view controller.
Use the popToViewController:animated: method provided by UINavigationController (details here)
You can get a reference to AViewController using the viewControllers property that UINavigationController provides
If your AViewController is the root vc of the nav controller, you can use the popToRootViewController:animated: method
Is it possible to have the following "view" structure?
1) RootViewController is a UITabBarController.
2) One of the "Tabbed" views is a UISplitViewController.
3) The "Detail" view of the "SplitViewController" is a UINavigationController.
What I'm trying to accomplish is the "Detail" view can create a sub view that has a "back" button.
The problem is calling PushViewController(newView, true) in my "Detail" view never displays the newView.
A UISplitViewController must the the top level controller.
See here: Split view controller must be root view controller
Instead of using a UITabBarController at the root, you should just use the split controller.
The detail and master sections will both have UINavigationControllers where you can push as many new screens as you need.
In my navigation based application, first view is sign in or signup view. After that i am using a view which is using tab view controller. That view has three tab items. Now i want to create a new view and push in navigationController. But its not working. But adding new view as subView in tabBarController View works. I want navigation for subViews for each tabBarItem? How can i do that?
See this
In your case just create three items and make them all UINavigationControllers like the first tab item in the above example.
I have a Navigation Controller with a root table view which has several links. Tapping each link moves to the next view (by pushing it to the navigation controller's stack). But suppose that in that "next view", I have a UIButton that should take me further to another view (by pushing on to the same navigation controller's stack)...
View Controller-->first view-->second view-->third view..........
Now, I can easily access the Navigation Controller when I deal with the first view (and successfully push it to the Navigation Controller's stack) because it has been instantiated in the same file itself. What my real doubt is--How do you access a Navigation Controller in a far off view controller (eg, the third view or fourth view etc)? Please note that I am not using any separate delegate. All the Navigation Bar methods have been implemented in one file and connected to the Navigation Controller via an outlet.
When you push a ViewController onto a NavigationController the ViewController will automatically have it's navigationController property set. This means you can access the same NAvigationController no matter where you are in the stack.
-Update-
navigationController
In every UIViewController you can access that property.
So to in any other UIViewController that has been pushed onto the stack you should be able to just do this:
[self.navigationController pushViewController:othercontroller animated:YES];
Look at the documentation for UIViewController to see what other magic properties you have available.
I'm starting an app where I'd like to have multiple view controllers. Some of the views will be displayed inside of a navigation controller. I can create a navigation controller and then add another instantiated view controller to it. But what I'd like to do, is just instantiate a view controller that has its own view and is the root view controller of a navigation view controller. So when I instantiate the view controller, I'd like for it create a navigation controller and push "self" on to it. When I do it my simulator crashes and the details don't really give a reason. The console does not display anything. Any ideas. My reason for this is to separate out logic without have a view controller that simply creates a navigation controller and then pushes another view controller on it as the root view controller.
I'm not entirely sure if I understand your question correctly. Why would it be preferable if the view controller pushed itself to the navigation controller? I mean, you have to instantiate your view controller at some point in code (either app delegate or another view controller) anyway. Why can't you just create the navigation controller there, instantiate your VC and then push it onto the nav controller? As far as I can see, this doesn't involve creating any additional view controllers.
Anyway, having a view controller decide by itself where it is used (ie. pushed onto), is not best practice. This way you lose the flexibility of using it in other contexts. Always try to couple your components as loosely as possible.