导航控制器作为第二个视图
在我的主视图控制器上,我有一个显示新视图的按钮。
- (IBAction)showInformation:(id)sender {
InfoViewController *controller = [[InfoViewController alloc] initWithNibName:@"InfoView" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[self.view addSubview:[controller view]];
在我的InfoView.xib
上,我添加了一个 UINavigationController 并进行了正确的连接。但是,当我加载 InfoViewController 时,它没有按照我想要的方式显示 UINavigation。
目前我在 viewDidLoad 上有这个
self.view = [navController view];
并且在头文件上我有
IBOutlet UINavigationController *navController;
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
我缺少什么?
On my main view controller I have a button that shows a new view.
- (IBAction)showInformation:(id)sender {
InfoViewController *controller = [[InfoViewController alloc] initWithNibName:@"InfoView" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[self.view addSubview:[controller view]];
}
On my InfoView.xib I added a UINavigationController and made the proper connections. However when I the InfoViewController loads is not showing the UINavigation as I want it to.
Currently I have this on viewDidLoad
self.view = [navController view];
And on the header file I have
IBOutlet UINavigationController *navController;
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UINavigation did not show 你的意思是UINavigationController没有出现?
1 如果您使用 UINavigationController,则至少需要两个视图:一个用于与控制器一起出现的默认视图,另一个用于推送两个视图。
我在这里只能看到一个视图,那就是 InfoViewController。
如果您使用UINavigationController,您可能需要使用pushViewController 方法。
2 如果使用presentModalViewController方法,则不需要UINavigationCOntroller。
UINavigation did not show you mean UINavigationController did not appear?
1 If you use UINavigationController, you need at least two views: one for the default view that appears with the controller and another that is pushed two.
I can only see one view here, which is InfoViewController.
If you use UINavigationController, you may want to use the pushViewController method.
2 If you use presentModalViewController method, no UINavigationCOntroller is needed.