iOS:在选项卡视图中弹出子视图

发布于 2024-12-18 12:35:56 字数 769 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩虹直至黑白 2024-12-25 12:35:56

您不需要 UINavigationController 的属性,而是希望将其推送到当前导航控制器上,如下所示:

NewWindowController *newWindow = [[NewWindowController alloc] initWithNibName:@"NewWindowController" bundle: nil];
[self.navigationController pushViewController:newWindow animated:YES];
NSLog(@"clicked");

当 UIViewController 与 UINavigationController 关联时(即它是导航控制器层次结构的一部分),则其 navigationController 属性将被设置,因此您可以像我所示的那样访问它。

You don't want a property for the UINavigationController, you want to push onto the current navigation controller like so:

NewWindowController *newWindow = [[NewWindowController alloc] initWithNibName:@"NewWindowController" bundle: nil];
[self.navigationController pushViewController:newWindow animated:YES];
NSLog(@"clicked");

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文