适当的方式做“条件segue”在iOS5中 [英] Proper way to do "conditional segue" in iOS5

查看:108
本文介绍了适当的方式做“条件segue”在iOS5中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写非常简单的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?

推荐答案

您可以通过从底部的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

这篇关于适当的方式做“条件segue”在iOS5中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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