title: How do I create UIViewController using Xib-file?
body: <p>Sorry if this question has already been answered but I can't find an answer.</p>
  
  <p>I'm creating an app in which I have an UITableViewController and when the accessorybutton in the right side of a cell is selected a new instance of a UIViewController should be created containing the interface found in a .xib-file. The new UIViewController will then be pushed on to the stack and displayed.
  My question is how do I create the new UIViewController from an existing .xib-file?</p>
  
  <p>This is what I have tried so far:
  In Xcode: File -> New File -> Cocoa Touch Class -> UIViewController subClass.
  Checkbox "UITableViewController subclass" unchecked.
  Checkbox "With XIB for user interface" checked.</p>
  
  <p>This creates a .m, a .h and a .xib file. I created a user interface in the "view" in the .xib-file. Selecting "File's owner" in interface builder shows the newly created UIViewController in "Class Identity".</p>
  
  <p>Some code:</p>
  
  <p>In DetailViewController.m (the new UIViewController):</p>
  
  <pre><code>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
       self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
       return self;
  }
  </code></pre>
  
  <p>In SubViewController.m (the old UITableViewController):</p>
  
  <pre><code>-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
       DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
       //Exception thrown at line below
       [self.navigationController pushViewController:detailViewController animated:YES];
       [detailViewController release];
  }
  </code></pre>
  
  <p>Forgot to mention that the .xib-file's name is "DetailViewController.xib".</p>
  
  <p>The code compiles fine but when I run it in the simulator and press an accessorybutton it terminates due to uncaught exception.</p>
  
  <p>What am I missing?</p>
  
  <p>Thanks in advance</p>