title: Adding NavigationControl to a TabBar Application containing UITableViews
body: <p>I'm new to iPhone dev and wanted to get advice on the general design pattern / guide for putting a certain kind of app together.</p>
  
  <p>I'm trying to build a TabBar type application. One of the tabs needs to display a TableView and selecting a cell from within the table view will do something else - maybe show another table view or a web page. I need a Navigation Bar to be able to take me back from the table view/web page.</p>
  
  <p>The approach I've taken so far is to:</p>
  
  <p>Create an app based around UITabBarController as the rootcontroller</p>
  
  <p>i.e.</p>
  
  <pre><code>@interface MyAppDelegate : NSObject &lt;UIApplicationDelegate&gt; 
  {
  IBOutlet UIWindow *window;
  IBOutlet UITabBarController *rootController;
  }
  </code></pre>
  
  <p>Create a load of UIViewController derived classes and associated NIBs and wire everything up in IB so when I run the app I get the basic tabs working.</p>
  
  <p>I then take the UIViewController derived class and modify it to the following:</p>
  
  <pre><code>@interface MyViewController : UIViewController&lt;UITableViewDataSource, UITableViewDelegate&gt; 
  {
  
  }
  </code></pre>
  
  <p>and I add the delegate methods to the implementation of MyViewController</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section         { 
  return 2;
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *CellIdentifier = @"Cell";
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  }
  
  if (indexPath.row == 0)
  {
      cell.textLabel.text = @"Mummy";     
  }
  else
  {
      cell.textLabel.text = @"Daddy";
  }
  return cell;
  }
  </code></pre>
  
  <p>Go back to IB , open MyViewController.xib and drop a UITableView onto it. Set the Files Owner to be MyViewController and then set the delegate and datasource of the UITableView to be MyViewController.</p>
  
  <p>If I run the app now, I get the table view appearing with mummy and daddy working nicely. So far so good.</p>
  
  <p>The question is how do I go about incorporating a Navigation Bar into my current code for when I implement:</p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath()
  {
  //  get row selected
  NSUInteger row = [indexPath row];
  
  if (row == 0)
  {
      //  Show another table
  }
  else if (row == 1)
  {
      //  Show a web view
  }
  }
  </code></pre>
  
  <p>Do I drop a NavigationBar UI control onto MyControllerView.xib ? Should I create it programmatically? Should I be using a UINavigationController somewhere ? I've tried dropping a NavigationBar onto my MyControllerView.xib in IB but its not shown when I run the app, only the TableView is displayed.</p>