问题描述
我正在尝试编写非常简单的 iOS5 应用程序,只搜索特定类型的数据.
I'm trying to write really simple iOS5 app just searching for specific type of data.
它包含两个屏幕,用户将一些数据放入第一个屏幕,应用程序检查数据,如果数据有效,应用程序将进行搜索并在新屏幕上显示结果.
It contains two screens, the user puts some data in the first, the app checks the data and if it is valid, the app will do a search and show result on new screen.
我对 iOS 和故事板完全陌生,我阅读了很多教程,但无法弄清楚如何检查输入并正确切换到新屏幕.
I'm completely new to iOS and storyboards, I read quite a few tutorials, but haven't been able to figure out how to do the checking of input and switching to new screen properly.
对于 iOS5,我想我应该使用 segue,但这都是自动的.即使我可以在 prepareForSegue 方法中添加一些代码,但如果检查失败,我找不到如何阻止 segue 发生的方法,或者我是否试图完全错误地这样做?
With iOS5 I guess I should use segue but that's all automatic. Even though I can put some code in prepareForSegue method, I couldn't find a way how to stop the segue from happening if the check fails, or am I trying to do it completely wrong?
推荐答案
您可以通过 ctrl 从底部的 viewController 图标拖动到目的地来创建通用"segue.此 segue 不会与任何操作相关联.然后在您的代码中,事件正在使用您想要触发 segue 调用的条件代码:
You can create "generic" segue by ctrl dragging from the viewController icon at the bottom to the destination. This segue won't be associated with any action. Then in your code where ever the event is using your conditional code that you want to trigger the segue call:
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
这篇关于做“条件转场"的正确方法在 iOS5 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!