开发者

How can I go to top level UINavigationController in one UITabBarController from another UINavigationController in another UITabBarController?

OK so this is the scenario:

I have a Tab bar application that has a UINavigationController in each tab. Lets say I have two tabs, "Home" and "Signout". In "Home" the user follows a UINavigation based nav开发者_运维技巧igation down 3 levels and presses submit. After that they click on "Signout", click on the signout button.

What I want to do is to:

Take the user back to the first tab "Home", and then do a "Pop to root navigation controller"

My code in Signout is :

[[self tabBarController]setSelectedIndex:0]; //this takes me to the first tab "Home"

[self.navigationController popToRootViewControllerAnimated:YES]; //this does not work

How do I get about doing this?


You need to invoke the pop command on the proper controller, ie do something like:

UIViewController *selectedController = [[self tabBarController] selectedController];
[[selectedController navigationController] popToRootViewControllerAnimated: YES];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜