Search code examples
iphonefacebook-graph-apisingle-sign-ontabbarpushviewcontroller

iPhone programmatically select Tab AND push view controller


With Facebook's new SSO, logging into Facebook means that my app is temporarily shut down. The problem is that my app requirements dictate that it cannot run in the background. So, when my app is brought back up, it is on the original tab/view controller.

I am trying to get things back to the facebook login view. This requires programmatically selecting a tab AND pushing from that tab to a separate view controller.

I can programmatically select a tab no problem:

[[UIApplication sharedDelegate].tabBarController setSelectedIndex:4];

But I cannot push the view controller from the newly selected tab. I've tried

AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped];
    ((AboutViewController *)nextViewController).hidesBottomBarWhenPushed = NO;
    [[[[[UIApplication sharedDelegate] tabBarController] selectedViewController ] navigationController] pushViewController:nextViewController animated:NO];
    [nextViewController release];

and

AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped];
    ((AboutViewController *)nextViewController).hidesBottomBarWhenPushed = NO;
    [[[[[UIApplication sharedDelegate] tabBarController] navigationController] pushViewController:nextViewController animated:NO];
    [nextViewController release];

Is it even possible to do this?


Solution

  • try this:

    AboutViewController *nextViewController = [[AboutViewController alloc] initWithStyle:UITableViewStyleGrouped]; 
    [[self.tabBarController.viewControllers objectAtIndex:4] pushViewController: nextViewController animated:NO]; 
    [nextViewController release];