开发者

Popping multiple levels in UITableViewController

开发者 https://www.devze.com 2022-12-26 03:42 出处:网络
I would like to be able to pop multiple views from a UITableViewController stack.For example in the Apple DrillDownSave example, when viewing Level 3 to go back to Level 1 or when viewing an Item to g

I would like to be able to pop multiple views from a UITableViewController stack. For example in the Apple DrillDownSave example, when viewing Level 3 to go back to Level 1 or when viewing an Item to go back to Level 2 when a button is pushed.

I tried:

[self.navigationController.parentViewController.navigationController popViewControllerAnimated: NO];
[self.开发者_开发知识库navigationController popViewControllerAnimated: NO];  

and

[self.navigationController popViewControllerAnimated: NO];  
[self.navigationController.parentViewController.navigationController popViewControllerAnimated: NO];

but these leave me the same place as just a single popViewControllerAnimated:. Is there an easy way to do this?


Thank you Giao that did it. I changed my code to:

NSArray *allViewControllers = self.navigationController.viewControllers;
NSInteger n = [allViewControllers count];
[self.navigationController popToViewController: [allViewControllers objectAtIndex: (n-3)] animated: YES];

and it works perfectly.


What you want is to send popToViewController: animated: to the navigation controller. You can use the navigation controller's viewControllers property to figure out which view controller it is that you want to pop to.

0

精彩评论

暂无评论...
验证码 换一张
取 消