开发者

3 questions about UINavigationController [duplicate]

This question already has an answer here: Close开发者_JAVA百科d 11 years ago.

Possible Duplicate:

UINavigationController

I've a stack of UIViewControllers handled by a UINavigationViewController.

  1. Let's say I'm at the UIViewController 7 and I want to come back to the number 2. What's the most convenient way to do it ?

  2. Let's say I dunno what number the destination UINavigationController is, and I want just to come back to "MyCustomViewController" (loaded on the stack). Is there a way to accomplish this ?

  3. My destination UIViewController is not on the stack. So I would like to get rid of the stack, and push it from the rootViewController. I'm currently on the UIViewController number 7. Which code to write exactly ?

thanks


  1. First get the list of view controllers ([navController viewControllers]) and get the 2nd view controller ([vcs objectAtIndex:1]). Then just call popToViewController: passing the controller you got before.

  2. Get the list of view controller classes ([[navController viewControllers] valueForKey:@"class"]) Then check the index of class MyCustomViewController ([vcClasses indexOfObject:[MyCustomViewController class]]). Get the index of that object, then just pop to that view controller using method described in item (1).

  3. Just pop to root view controller and push your wanted view controller afterwards.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜