sergiocg90
sergiocg90

Reputation: 499

PopToRootViewController when pressing the selected Tab of a CustomTabBar

Well, I have a custom TabBar to add a center raised tab on my app. So I have a CustomTabBarViewController. I would like to make it work like apps like Twitter. When a selected tab is pressed a PopToRootViewController will be made. I have my raised tab bar method called when it's pressed but I don't know what to add inside the if sentence. Any suggestion?

Here is the code I mentioned inside my CustomTabBarViewController

- (void) raisedTabPressed
{
    if (raisedButton.selected)
    {
        //Code to PopToRootViewController
    }

    raisedButton.selected = YES;
    [self setSelectedIndex:1]; 
}

Upvotes: 1

Views: 687

Answers (1)

sergiocg90
sergiocg90

Reputation: 499

Well, I found an Answer for my own question. The code inside the if sentence will be:

UINavigationController *navController = (UINavigationController *)[self selectedViewController];
[navController popToRootViewControllerAnimated:YES];

Upvotes: 2

Related Questions