ios segue“取消” [英] ios segue "cancel"

查看:84
本文介绍了ios segue“取消”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据XML返回,我不希望当前的 segue 在UIButton touch上执行。

Depending on an XML return, I don't want the current segue to perform on UIButton touch.

我知道我可以选择哪个 segue 我想执行,但是如何制作 segue 执行?或者至少不执行任何可用的 segues

I know I can pick which segue I want to perform, but how to I make a segue not perform? Or at least not perform any of the available segues?

推荐答案

如果您的部署目标是iOS 6.0或更高版本,则可以覆盖 - [UIViewController shouldPerformSegueWithIdentifier:sender:] 方法到返回 YES 如果你想执行segue而如果你不想。

If your deployment target is iOS 6.0 or later, you can override the -[UIViewController shouldPerformSegueWithIdentifier:sender:] method to return YES if you want to perform the segue and NO if you don't.

如果您的部署目标早于iOS 6.0,则不会收到 shouldPerformSegueWithIdentifier:sender:消息。所以在你的故事板中,不要从按钮中绘制segue。而是从按钮的视图控制器中绘制segue并为segue指定标识符。将按钮连接到其视图控制器中的 IBAction 。在操作中,检查是否要执行segue。如果您想执行它,请发送给自己 performSegueWithIdentifier:sender: ,将您分配给标识符的标识符传递给故事板。

If your deployment target is earlier than iOS 6.0, you won't receive the shouldPerformSegueWithIdentifier:sender: message. So in your storyboard, don't draw the segue from the button. Instead, draw the segue from the button's view controller and give the segue an identifier. Connect the button to an IBAction in its view controller. In the action, check whether you want to perform the segue. If you want to perform it, send yourself performSegueWithIdentifier:sender:, passing the identifier you assigned to the segue in the storyboard.

这篇关于ios segue“取消”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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