iOS:在选项卡视图中弹出子视图
iOS 新手问题——我真的很困惑导航视图在选项卡视图中的工作方式。
现在我有一个有 2 个视图的选项卡视图。在第二个选项卡中我有一个按钮。单击该按钮时,我希望显示一个包含一些信息的新窗口,并且新窗口需要在顶部有一个“后退”按钮,用于返回到第二个选项卡。
我遵循了一些教程,并将 NavigationController
放入 secondTab.xib 中,将该行添加
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
到 secondTab.h 以及
NewWindowController *newWindow = [[NewWindowController alloc] initWithNibName:@"NewWindowController" bundle: nil];
[self.navController pushViewController:newWindow animated:YES];
NSLog(@"clicked");
我的 按钮实现中>-(IBAction) click: (id)sender
当我单击第二个选项卡中的按钮时,日志显示“已单击”,但我的视图没有更改。
我需要更改文件所有者/导航控制器出口/引用出口等的某些设置吗?
谢谢!
Newbie question for iOS -- I'm really confused with how navigation view works in a tabview.
Right now I have a tabview that has 2 views. In the second tab I have a button. When the button is clicked I'd like a new window to show up with some information, and the new window needs a Back button on top that goes back to the second tab.
I followed some tutorials and put a NavigationController
in secondTab.xib, added the line
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
to secondTab.h, and
NewWindowController *newWindow = [[NewWindowController alloc] initWithNibName:@"NewWindowController" bundle: nil];
[self.navController pushViewController:newWindow animated:YES];
NSLog(@"clicked");
to my button implementation for -(IBAction) click: (id)sender
When I clicked the button in my second tab, the log shows "clicked" but my view is not changing.
Is there some setting I need to change for File's Owner/Navigation Controller outlets/referencing outlets etc...?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要 UINavigationController 的属性,而是希望将其推送到当前导航控制器上,如下所示:
当 UIViewController 与 UINavigationController 关联时(即它是导航控制器层次结构的一部分),则其
navigationController
属性将被设置,因此您可以像我所示的那样访问它。You don't want a property for the UINavigationController, you want to push onto the current navigation controller like so:
When a UIViewController is associated with a UINavigationController (i.e. it's part of a navigation controller hierarchy) then its
navigationController
property will be set, so you can access it like I've shown.