-1

Is it possible to dismiss 2 viewControllers efficiently?

I currently have 3 (or more) viewControllers.

View1 > presents View2 , View2 > presents View3, etc.. then when an action is triggered in View3 (or 4,5..), I need to return to the View1.

How is this done without creating a new View1 object?

Can i dissmis for example view2 in the same time when presenting view3?

Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74
  • Hows your view hierarchy looks like ? It's difficult to answer without knowing how you've setup your views. – greenhorn Mar 05 '12 at 22:11
  • possible duplicate of [iPhone - dismiss multiple ViewControllers](http://stackoverflow.com/questions/2944191/iphone-dismiss-multiple-viewcontrollers) – Sklivvz Mar 06 '12 at 21:15

3 Answers3

0

Have a look at popViewControllerAnimated: NO and popToRootViewController.

You can also do smth. like that:

UINavigationController* navController = ...;
[navController popViewControllerAnimated: NO];
[navController popViewControllerAnimated: NO];
[navController pushViewController: anotherViewController];
calimarkus
  • 9,955
  • 2
  • 28
  • 48
  • because view1 is tabbar, and view2 is subview of tabbar. it is hard to explain, but i cant use UINavController here – Eugene Trapeznikov Mar 05 '12 at 19:18
  • then please tell us your code structure based on what classes are used in your view structure... or show some code. otherwise nobody can help you. – calimarkus Mar 05 '12 at 20:25
0

if you are using navigation controller..

then you can just use

[ self.navigationController popToRootViewControllerAnimated:YES];  

other wise.. you can use delegate in each view and call

[self dismissModalViewControllerAnimated:NO];

in each view except in view 1 where you should call

[self dismissModalViewControllerAnimated: YES];
Shubhank
  • 21,721
  • 8
  • 65
  • 83
0

i creating view2 like UINavController. And then in every controller i can implement dismissModalViewControllerAnimated.

Thnks every body for help

Eugene Trapeznikov
  • 3,220
  • 6
  • 47
  • 74