如何在 iOS 5 中执行与用户输入无关的转场? [英] How to perform a segue that is not related to user input in iOS 5?

查看:11
本文介绍了如何在 iOS 5 中执行与用户输入无关的转场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一个带有按钮的视图.我们可以从这个按钮拖动一个连接到其他视图控制器,在 IB 中创建一个 segue,我们很高兴.如果我需要在某些事件(例如网络进度)上执行的转场,并且与任何用户操作无关怎么办?现在我正在放置一个按钮,从这个按钮拖动一个segue,隐藏按钮,为一个segue分配一个标识符,然后在我执行这个segue的代码中的某个地方.但是,我认为放置一个虚拟按钮不是正确的方法.可能我在使用故事板时遗漏了一些东西,你能帮我理解吗?

Consider a view with a button. We can drag a connection from this button to some other view controller, create a segue in IB and we are happy. What if I need a segue that is performed upon some event, say, network progress, and that is unrelated to any user actions? For now I'm placing a button, drag a segue from this button, hide the button, assign an identifier to a segue and somewhere in the code i perform this segue. However, I think that placing a dummy button is not a right way. Possibly I'm missing something using storyboards, could you please help me to understand this?

推荐答案

通过 ctrl 从视图控制器拖动到下一个视图来创建 segue.然后调用你的 segue,调用:

Create your segue by ctrl dragging from your view controller to your next view. Then to call your segue, call:

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

确保您在故事板中为您的 segue 命名.

Make sure you give your segue a name in the storyboard.

这篇关于如何在 iOS 5 中执行与用户输入无关的转场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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