如何创建条件转场 [英] How to Create a Conditional Segue

查看:20
本文介绍了如何创建条件转场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用故事板在 Xcode 中创建了一个项目.我使用单击和拖动方法在两个带有按钮的视图控制器之间创建了一个 segue.但是,为了使 segue 发生,我希望满足一组特定条件.所以我已经将按钮编码为IB动作并在实现文件中编写了条件代码.如果条件不满足,会弹出一个警告视图,我不希望发生转场.但如果满足条件,那么我确实希望发生转场.

I have created a project in Xcode using storyboards. I created a segue between two of the view controllers with a button using the click and drag method. However, there are a certain set of conditions that I want to be met in order for the segue to happen. So I already coded the button as an IB action and wrote the conditional code in the implementation file. If the conditions are not met, an alert view pops up, and I don't want the segue to happen. But if the conditions are met then I do want the segue to happen.

有没有办法以编程方式命令在 IB 动作函数内发生或不发生转场?或者有什么其他方法可以得到同样的结果?

Is there any way to programmatically command a segue to happen or not happen inside an IB action function? Or any other way to get the same kind of result?

谢谢!任何帮助表示赞赏!

THANKS! Any help is appreciated!

推荐答案

我找到了一个很好的解决方案,有人发布了...创建一个源自原始视图控制器状态栏的 segue,给它一个标识符,然后在操作按钮中添加以下代码:

I found a great solution for this that someone posted... create a segue that originates from from the status bar of the originating view controller, give it an identifier, and then add this code inside the action button:

[self performSegueWithIdentifier:@"identifierName" sender:sender]; 

效果很好!

这篇关于如何创建条件转场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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