在 iOS 5 Storyboard 中,如何将新场景从 Popover 推送到原始视图控制器?

发布于 2024-12-10 05:28:21 字数 1151 浏览 6 评论 0原文

我正在从新的视图控制器创建 popoverSegue,并希望将第三个视图控制器推送到原始堆栈上。这就是我创建应用程序的方式:

  1. 创建一个新的单视图应用程序
  2. 选择使用 Storyboards
  3. 选择MainStoryboard.storyboard 文件。
  4. 选择唯一的View Controller,将TitleIdentifier更改为initialView,然后选择Editor->Embed In->Navigation控制器
  5. 将两个新的View Controller 对象从对象库拖到画布上,
  6. 将新视图控制器的TitleIdentifier 更改为: popoverViewnewView
  7. 将对象库中的 Round Rect Button 对象添加到 initialViewpopoverView
  8. 将对象库中的 Label 对象添加到 `newView.
  9. Control 单击 initialView 中的按钮并拖动到 popoverView
  10. 从出现的 Storyboard Segues 菜单中选择 Popover 选项。
  11. Control 单击 popoverView 中的按钮并拖动到 newView
  12. Storyboard Segues 菜单中选择Push 选项。
  13. 构建&跑步。

单击第一个按钮,弹出窗口出现,但是当您单击弹出窗口中的按钮时,没有任何反应(它应该推送新视图,但没有。)

想要做的是它推入导航控制器堆栈,但我不确定如何为此设置故事板。

有什么想法吗?

I'm creating a popoverSegue from a new view controller and want to push a third view controller onto the original stack. This is how I'm creating the application:

  1. Create a new Single View Application
  2. Select Use Storyboards
  3. Select the MainStoryboard.storyboard file.
  4. Select the only View Controller, change the Title and Identifier to initialView, then select Editor->Embed In->Navigation Controller
  5. Drag two new View Controller objects from the Objects Library onto the canvas
  6. Change the Title and Identifier of the new View Controllers to: popoverView and newView.
  7. Add a Round Rect Button object from the Object Library to initialView and popoverView.
  8. Add a Label object from the Object Library to `newView.
  9. Control click the button in the initialView and drag to popoverView.
  10. Select the Popover option from the Storyboard Segues menu that appears.
  11. Control click the button in the popoverView and drag to the newView.
  12. Select the Push option fromt the Storyboard Segues menu.
  13. Build & Run.

Click the first button, and the popover appears, but when you click the button within the popover, nothing happens (it should push the new view but doesn't.)

What I want to do is for it to push onto the Navigation Controller stack, but am not sure how to setup the storyboard for that.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

谁把谁当真 2024-12-17 05:28:21

您期望 UINavigationController 层次结构将自身扩展为呈现的弹出窗口。不会的。呈现模态视图控制器也是如此。如果您要在 popoverView 中记录 self.navigationController,您会看到它为 nil。

popoverView 嵌入到它自己的 UINavigationController 中。请记住,如果您要覆盖 prepareForSegue:sender: 并尝试配置弹出窗口,则需要从 destinationViewController 获取 topViewController 作为目的地现在是 UINavigationController 的一个实例。

You're expecting the UINavigationController hierarchy to extend itself into a presented popover. It won't. The same goes for presenting modal view controllers. If you were to log self.navigationController in popoverView, you would see that it is nil.

Embed popoverView into it's own UINavigationController. Remember that if you're overriding prepareForSegue:sender: and attempting to configure the popover, you will need to get the topViewController from destinationViewController as the destination is now an instance of UINavigationController.

薄情伤 2024-12-17 05:28:21

听起来应该可行,但如果不起作用,请尝试以下操作:
1. 单击不起作用的 segue 并为其指定一个标识符。假设它是 PopoverToNewSegue。

  1. 在弹出视图控制器的实现文件中,在单击按钮时添加一个操作。

  2. 该函数应返回 void 并添加以下行:
    [self PerformSegueWithIdentifier:@"PopoverToNewSegue" sender:self];

这应该能让你的segue运行起来。我注意到转场并不总是像你期望的那样工作,但是这个对我来说毫无失败。

Sounds like it should work, but if it doesn't try the following:
1. Click the segue that doesn't work and give it an identifier. Let's say it's PopoverToNewSegue.

  1. In your implementation file for the popover view controller, add an action when the button is clicked.

  2. That function should return void and add the following line:
    [self performSegueWithIdentifier:@"PopoverToNewSegue" sender:self];

That should get your segue running. I've noticed that segues don't always work like you expect them to, but this one works for me without fail.

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