title: Custom iOS UITabBarController Delegate Triggers viewDidLoad
body: <p>Issue:</p>
  
  <p>An UITabBarController delegate method calls viewDidLoad and negates/ignores the screen selection.</p>
  
  <p>Background:</p>
  
  <p>I am making a split-view controller for small iOS screens. So, far the screen looks something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/xUbAh.jpg" rel="nofollow noreferrer">Custom Split-View Controller</a></p>
  
  <p>For the Detail View (RS), I'm using a UITabBarController, with the TabBar removed. You can find the code for this <a href="https://stackoverflow.com/a/13934718">here</a>. </p>
  
  <p>The user selects the buttons on left, and a delegate sends the button's tag id to the UITabBarController delegate method.</p>
  
  <p>The delegate method looks like this:</p>
  
  <pre><code>// delegate method in subclass of UITabBarController
  -(void) screenSelected:(int)screenNum
  {
      NSLog(@"delegate arrived: %d", screenNum);
      self.selectedIndex = screenNum;
      // code goes to viewDidLoad
  }
  </code></pre>
  
  <p>With breakpoints in place, I determined that the screen does not actually change.</p>
  
  <p>If this screenSelected method is instead called from the UITabBarController viewDidLoad method (when the app first opens), the method works fine and the selectedIndex is changed as expected.</p>
  
  <p>I'm trying to figure out why the delegate is triggering viewDidLoad. Does the delegate reset the view?</p>
  
  <p>Thanks</p>