title: tab does not switch programmatically for a tabBar inside a navigation controller
body: <p>My app starts with a navigation controller which opens a UIViewController. This screen works as a login page.</p>
  
  <p>On login, I open a UITabBarController like this:</p>
  
  <pre><code>  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
      UITabBarController *obj=[storyboard instantiateViewControllerWithIdentifier:@"MainTab"];
      self.navigationController.navigationBarHidden=YES;
      [self.navigationController pushViewController:obj animated:YES];
  </code></pre>
  
  <p>Inside my tab bar controller, I want when clicking a button to switch tab programmatically. I tried the following 3, neither of them worked. Code is place inside a method, which is invoked when the button is clicked.</p>
  
  <p>For the first 2, the tab didn't change - still my initial tab is highlighted and the correct view controller is not shown. For the last one, app crashes.</p>
  
  <p>1st :</p>
  
  <pre><code>  self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:1];
  </code></pre>
  
  <p>2nd :</p>
  
  <p>[self.parentViewController.tabBarController setSelectedIndex:1];</p>
  
  <p>3rd:</p>
  
  <pre><code>UITabBarController *MyTabController = (UITabBarController *)((AppDelegate*) [[UIApplication sharedApplication] delegate]).window.rootViewController;
  [MyTabController setSelectedIndex:1];
  </code></pre>
  
  <p>What am I missing?</p>