title: iPhone - how do I add a navigation controller to a view?
body: <p>I currently have an application that does the the following:</p>
  
  <p><strong>S:</strong> Loads a view as a login screen to start with.</p>
  
  <p><strong>a:</strong> If login is successful I add a terms and conditions screen as a subview</p>
  
  <p><strong>b:</strong> If not successful I add a sign up form as a subview</p>
  
  <p><strong>F:</strong> Then I load the main part of my app on success of either of the a or b which is the part of the app where there is a navigation controller and a tab bar controller. This is set up in MainWindow.xib</p>
  
  <p><strong>S</strong>, <strong>a</strong> and <strong>b</strong> also have Nav bars but no navigation controllers as I didn't think I would need navigation control on the login screens.</p>
  
  <p>However it turns out I do, I want to be able to have back navigation from both <strong>a</strong> and <strong>b</strong> to the initial login screen.</p>
  
  <p>I have tried several ways of doing this including trying the following answers:</p>
  
  <p><a href="https://stackoverflow.com/questions/4386926/how-to-add-navigation-controller-in-view-based-application-in-iphone">How to add navigation controller in View Based Application in iPhone?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2389099/how-do-you-properly-set-up-a-secondary-view-to-support-a-navigation-controller-on">How do you properly set up a secondary view to support a navigation Controller on the iPhone?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2415525/how-to-add-navigation-controller-programatically">how to add navigation controller programatically?</a></p>
  
  <p>But none of them work for me, they display the new Navigation controller over the login screen and dont load the a or b screens.</p>
  
  <p>I'm guessing this is because I am adding them as subviews to my loginView and this is not the correct way to do this? My code is as follows:</p>
  
  <pre><code> if(self.tcSubViewController == nil){
  
          TCSubViewController *_tcSubViewController = [[TCSubViewController alloc] initWithNibName:@"T&amp;CView" bundle:[NSBundle mainBundle]];
  
          self.tcSubViewController = _tcSubViewController;
  
          [_tcSubViewController release];
  
      }
   [self.view addSubview:[tcSubViewController view]];
  </code></pre>
  
  <p>I'm guessing there's a fundamental flaw in the way my Login flows? I should be able to completely remove the LoginView and then display the Terms and conditions view without having to add it as  subview, shouldn't I?</p>