I implemented 4 views in AppDelegate depends on requirement it will call the view.I called second(example) view then I pushed to the new view again I pushed to the other new view.I want to go back to the second(example) view. I implemented the code like this [self.navigationController popToRootViewControllerAnimated:YES]; but it is poping to previous view and again it go back to the second(example) view. Can any one tell me how it goes directly to the second(example) view.
Thanks in advance.
Instead of using popToRootViewController you need to use popToViewController like bellow
self.navigationController popToViewController:secondViewObj animated:YES];
You should use
popViewControllerAnimated:animated]
or
popToViewController:yourVC animated:animated]
Use [pushViewController:obj animated:NO].....
Though this will not pop your view, but it will push your view to obj that is object of FirstView.
This will simply work as you want, may be not technical way...:)
Related
I am using navigation bar on my application for reach next views in my iphone application.
in a stage of view I want reach back my first view.How can i do it please give me suggestion.Thanks.
There is a popToRootViewControllerAnimated: method that will remove all controllers from the stack and return the user to the first view controller.
See the Apple docs.
[self.navigationController popToRootViewControllerAnimated:YES];
This call will take you to the root of your view controllers
You need to use to go back to your previous view
[self dismissModalViewControllerAnimated:YES];
Hope it helps.
The UINavbarcontroller will go back to the previous VC when i press the Left button on the NavBar. Works as expected.
I also need to force the screen to go back from another button, so was wondering is there something i can call to make this happen? I dnt see any method attached to UINavbarController docs for this.
try popViewController:
[self.navigationController popViewControllerAnimated:YES];
Try looking at the UINavigationController docs instead, it's the fourth of 8 instance methods:
popViewControllerAnimated:
Pops the top view controller from the navigation stack and updates the
display.
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
So, I am using a RootViewController from which you can display first ViewController Categories and then from Categories you display next ex. Music
RootViewController -> Categories -> Music
In RootViewController I use this
[self presentModalViewController:categoriesView animated:NO];
to present the modal view and then dismiss it from Categories with
[self dismissModalViewControllerAnimated:NO];
From Categories to Music I use again
[self presentModalViewController:fruitView animated:NO];
to present the Music modal view and then dismiss it in music with again the same as above.
Is there a possibility to dismiss two modal views? I want a method that leads from Music back to RootViewController, dismisses both last modal views.
Any ideas?
Hi Use this Following code[[[self presentingViewController] presentingViewController] dismissModalViewControllerAnimated:YES];
Are you sure you want to use modal views for this? It sounds like what you're trying to do is better solved with a UINavigationController, where you can push and pop view controller's in a stack (and there's a popToRootViewControllerAnimated: message you can use).
This is how drill-down navigation is idiomatically handled in iOS (in the iPod, Notes, Contacts, Videos, Photos apps for example).
There's sample code for this in Xcode, I believe.
UINavigationController has a popToRootViewControllerAnimated: method, which per the documentation:
Pops all the view controllers on the
stack except the root view controller
and updates the display.
Use popToRootViewControllerAnimated method of UINavigationController.
[self.navigationController popToRootViewControllerAnimated:YES];
What you're talking about here, going from more general to more specific views, is better handled with a UINavigationController pushing and popping views. These are the views which slide left and right on the screen. Pushing means it slides in from the right (and shows a new, more specific view). Popping slides back to the right and shows a more general view.
A modal view controller is the one that slides in from the bottom of the screen. Look at the iPod app on your device for the way to handle this.
I use a nice utility method to do this... see here:
How to dismiss the two or more dismissModalViewController?
Use This, In music view write this for dissmiss 2 view .
[RootViewController dismissModalViewControllerAnimated:YES];
Here RootViewController is an object of RootViewController
Hope this will help u.
I am using a UINavigationController to slide from a UITableViewController to another view. In that second view I have created a custom "Back" button which is attached to an action.
What code do I use to return to dismiss the current view and slide back to my first view? I need something that is the equivalent to [super dismissModalViewControllerAnimated:true]; but obviously this is not a modal view.
Thanks.
Look at one of the following three methods on your navigation controller:
popViewControllerAnimated:
popToRootViewControllerAnimated:
popToViewController:animated:
Depending on how you want to handle it of course. Generally one just uses the first method to go back to the last view (the one that pushed your current view onto the navigation stack).
Use popToRootViewControllerAnimated method in UINavigationController:
[self.navigationController popToRootViewControllerAnimated:animated];
i'm working on iphone app which will show 4 buttons in first view. on click of a button, it will load a new view with navigation controller. this navigation controller view allows to travel upto 11 sub views. in 11th sub view, i've a reset button. on click of reset button, i've to go back to navigation controllers first view without traversing all the 11 views? is it possible to achieve it? if yes how? if no, what can be the solution?
You can also use the:
[self.navigationController popToRootViewControllerAnimated:YES];
u can use [self.navigationController popToViewController:objFirstViewController animated:YES] in the 11th view when you want to pop directly to the first view.
And if you are sure that you have to move to the first view and it is a rootviewcontroller then you can directly use
[self.navigationController popToRootViewControllerAnimated:YES];
Happy Coding..