从 Storyboard 中的模态视图推送视图控制器 [英] Push View Controllers from Modal View in Storyboard

查看:47
本文介绍了从 Storyboard 中的模态视图推送视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用故事板并有一个以模态呈现的屏幕,然后我需要从中推送其他视图控制器,以便我可以为模态视图选择项目(类似于在 iPhone 日历应用程序上添加条目).所以我要从:

I am using storyboard and have a screen which is presented modally, which I then need to push other view controllers from so that I can select items for the modal view (similar to adding an entry on the iPhone Calendar app). So I am going from:

导航控制器 > VC > 模态视图控制器 > ???这里我想推送一个 VC 以便我可以选择一个项目以返回到模态视图.

Navigation Controller > VC > Modal View Controller > ??? Here I want to push a VC so that I can select an item to return to the modal view.

我如何才能做到这一点,因为我目前收到错误只有当源控制器由 UINavigationController 的实例管理时才能使用推送转场."

How can I make this possible as I'm currently getting an error "Push segues can only be used when the source controller is managed by an instance of UINavigationController."

好的,现在我已经按照您说的进行了设置,现在尝试使用以下方法在视图控制器上设置属性时出错(我之前使用的是推送控制器):

Ah ok, so I now have it setup like you said, I now get an error when trying to set a property on the view controller (I was using a push controller before) using the following:

SetTransactionDateViewController *stdvc = (SetTransactionDateViewController *)[segue destinationViewController]; 
// Get the day to pass to the select date controller
stdvc.transactionDate = [Utilities convertStringToDate:cellDate.detailTextLabel.text:FORMAT_DD_MMM_YYYY]; 

"[UINavigationController setTransactionDate:]: 无法识别的选择器发送到实例"

"[UINavigationController setTransactionDate:]: unrecognized selector sent to instance"

推荐答案

当您分配以模态呈现的视图时,您需要确保该视图嵌入在 UINavigationViewController 中.导航控制器是必需的,以便您像您描述的那样执行转场.

When you allocate the view that you are presenting modally, you need to make sure that this view is embed inside of a UINavigationViewController. Navigation Controllers are required in order for you to do segues like the one you described.

您的故事板应如下所示:

Your storyboard should look like so:

这篇关于从 Storyboard 中的模态视图推送视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆