简体   繁体   English

从故事板中的模态视图推送视图控制器

[英]Push View Controllers from Modal View in Storyboard

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). 我正在使用故事板并且有一个模态显示的屏幕,然后我需要推送其他视图控制器,以便我可以为模态视图选择项目(类似于在iPhone日历应用程序中添加条目)。 So I am going from: 所以我要从:

Navigation Controller > VC > Modal View Controller > ??? 导航控制器> VC>模态视图控制器> ??? Here I want to push a VC so that I can select an item to return to the modal view. 在这里,我想推送VC,以便我可以选择一个项目返回到模态视图。

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." 我怎么能使这成为可能,因为我当前收到错误“推送segues只能在源控制器由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:]: unrecognized selector sent to instance" “[UINavigationController setTransactionDate:]:无法识别的选择器发送到实例”

When you allocate the view that you are presenting modally, you need to make sure that this view is embed inside of a UINavigationViewController . 当您分配要以模态方式呈现的视图时,需要确保将此视图嵌入到UINavigationViewController Navigation Controllers are required in order for you to do segues like the one you described. 导航控制器是必需的,以便您像您描述的那样进行分段。

Your storyboard should look like so: 你的故事板应该是这样的: 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM