Deepak Thakur
Deepak Thakur

Reputation: 3691

Get back to root view when tab is selected

With reference to this link I added UITabDelegate and UITabBarControllerDelegate in AppDelegate.h and added

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    if ([viewController isKindOfClass:[UINavigationController class]])
    {
        [(UINavigationController *)viewController popToRootViewControllerAnimated:NO];
    }
}

in AppDelegate.m. Still the issue is not solved. I am using XIB in my project and handling login and logout to enable and disable tab bar accordingly.

Upvotes: 0

Views: 638

Answers (1)

Bhumeshwer katre
Bhumeshwer katre

Reputation: 4671

You should write this:

if ([viewController isKindOfClass:[ClassName_Of_Selected_ViewController class]])
    {
        //[(UINavigationController *)viewController popToRootViewControllerAnimated:NO];
        [viewController.navigationController popToRootViewControllerAnimated:NO];
    }

Upvotes: 2

Related Questions