title: How to add an UINavigationController to an existing UIViewController programmatically
body: <p>I am newbie to iOS programming, and this problem may seem stupid to someone, I am sorry. 
  I have a problem here is that I have an existing UIViewController (A), and another UIViewController (B), I want to add an UINavigationController to A such that when I press a button on A, I will be lead to B. I tried the following approach, but it does not solve the problem:</p>
  
  <p>in AppDelegate:</p>
  
  <pre><code>@synthesize navigationController;
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
      // Override point for customization after application launch.
  
      self.tabbarController = [[UITabBarController alloc] init];
      UIViewController *viewController_1 = [[WUSTLViewController_1 alloc] init];
      UIViewController *viewController_2 = [[WUSTLViewController_2 alloc] init];
  
      UIViewController *viewController_3 = [[WUSTLViewController_3 alloc] init];
      navigationController = [[UINavigationController alloc] initWithRootViewController: viewController_3];
  
      self.tabbarController.viewControllers = [NSArray arrayWithObjects:viewController_1, viewController_2, navigationController, nil];
      self.window.rootViewController = self.tabbarController;
  
      self.window.backgroundColor = [UIColor whiteColor];
      [self.window makeKeyAndVisible];
      return YES;
  }
  </code></pre>
  
  <p>In WUSTLViewController_3.h (A):</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "WUSTLViewController_4.h"
  
  @interface WUSTLViewController_3 : UIViewController {
      WUSTLViewController_4 *viewController_4;
  }
  
  @property UINavigationController *navigationController;
  
  @end
  </code></pre>
  
  <p>In WUSTLViewController_3.m (A):</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
      viewController_4 = [[WUSTLViewController_4 alloc] init];
  
      UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
      myButton.frame = CGRectMake(80, 50, 150, 40);
      [myButton setTitle:@"Push" forState:UIControlStateNormal];
      [myButton addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:myButton];
  }
  
  - (IBAction)pressButton:(id)sender
  {
      [self.navigationController pushViewController:viewController_4 animated:YES];
  }
  </code></pre>
  
  <p>When I click the button, nothing happened.</p>