开发者

UINavigation Controller subview Problem

In my application my first Page is a UITableviewController. Then I add a subView in UIViewcontroller like:

viewcontrollername * prod=[[viewcontrollername alloc]init];
[self.view addSubview:prod.view];

It's fine, but My problem is in UINavigation controller not working in viewcontroller page(doesn't Navigate to another Page). I have implemented it in click event:

prod *login=[[prod alloc]init];
UINavigationController *navCtrl= [[UINavigationController alloc] init];
[navCtrl pushViewControlle开发者_StackOverflowr:login animated:YES];
[login release];

And

  prod *login=[[prod alloc]init];
 [self.navigationController pushViewController:login animated:YES];
 [login release];

But it doesn't Navigate to another Page.


Use this code when you init the navigation controller :

UINavigationController *navigationCtrlSlideShowSetting = [[UINavigationController alloc] initWithRootViewController:yourviewcontroller];

Thanks


It looks like navCtrl hasn't been added to the view hierarchy. Either you add it as a subview to the window or make it the rootViewController.


Your first view controller should be the root view controller of the navigation controller.

initWithRootViewController

Alternatively you can add the newly created navigation controller to your viewcontroller.

[self.view addSubview:navCtrl.view];

Once this is done you can push view controllers to the navigation controller.

EDIT: You need to have a back button in case you do not have a way to come back to main screen. The better option is to use navigation controller for the main screen and go on pushing views onto the stack.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜