How to add navigation controller in View Based App

2019-08-15 07:16发布

问题:

My application is view based appln. So how can i implement navigation controller in my apps.

If i have used this code, my controller works fine.

   FirstClass *first = [[FirstClass alloc] initWithNibName:@"FirstClass" bundle:nil];

   [self presentModalViewController:first animated:NO];

But using navigation controller in my apps, the navigation controller doesn't work.

    FirstClass *first = [[FirstClass alloc] initWithNibName:@"FirstClass" bundle:nil];

    UINavigationController *navigNews = [[[UINavigationController alloc] initWithRootViewController:first] autorelease(or retain)];

    [self.navigationController pushViewController:navigNews animated:YES];

So how can i add the navigation controller in my application. If i have added the navigation controller in my root view, i have faced some problem. so how can i add the navigation controller in the particular view.

Please help me out.

Thanks!

回答1:

Try adding:

[self.view addSubview:navigNews.view];