开发者

NavController Logout

开发者 https://www.devze.com 2023-03-09 13:49 出处:网络
I have NavController\'s inside 3 of my TabBarController of my app.开发者_如何学C When I go to the logout function in my app and logout, which is in TabBarController no.2, I made it return to TabBarCon

I have NavController's inside 3 of my TabBarController of my app.开发者_如何学C When I go to the logout function in my app and logout, which is in TabBarController no.2, I made it return to TabBarController no.1. However, it does not go back to the root of the NavController of tab 1.

I have referenced the NavController in the appDelegate just how I did with the TabBarController but I could not do what I did with the TabBarController with setSelectedIndex.

How can I make my NavController go back into the first view?

Thanks.

Code

    if ([buttonTitle isEqualToString:@"Logout"]) {

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    UITabBarController *tabBarController = appDelegate.rootController;
    ProductsNavController *productsNavController = appDelegate.productsNavController;

    [tabBarController setSelectedIndex:0];

This is what I did for the tabBar, can I do something like this for the Nav?


Did you call popToRootViewControllerAnimated: as mentioned in the documentation?

After your update, try this:

[…]
[tabBarController setSelectedIndex:0];
[appDelegate.productsNavController popToRootViewControllerAnimated:NO];
0

精彩评论

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