title: Select tab from UITabBarController programmatically and load view
body: <p>I am having an issue loading the view of selected tab item.</p>
  
  <p>I am using the code below in the <code>viewDidLoad</code> of the <code>UIViewController</code> at item 1 of the <code>UITabBar</code>.</p>
  
  <pre><code>UITabBarController *tab = self.tabBarController;
  
  if (tab){
     NSLog(@"I have a tab bar");
     [self.tabBarController setSelectedIndex:1];
     [self.tabBarController.view setNeedsDisplay];
     self.tabBarController.selectedIndex=1;
  } else {
      NSLog(@"I don't have");
  }
  </code></pre>
  
  <p>When I press Back To Tab Controller Button, it selects the tab but it doesn't open the required view. It shows the view of the tab at index 0. </p>
  
  <p><img src="https://i.stack.imgur.com/U29Du.png" alt="enter image description here"></p>