手动使用Segue [英] Using Segue Manually

查看:122
本文介绍了手动使用Segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从同一个按钮创建两个Segue,然后我想以编程方式选择根据设备方向使用哪一个。我遇到的问题是你似乎只能创建一个从按钮到另一个视图的segue,所以当我添加第二个时,它只会改变第一个。

I need to create two Segue's from the same button, and then I want to programatically choice which one to use based on device orientation. The problem I'm having is that you can only seem to create one segue from a button to another view so when I add the second one it just changes the first.

如何添加一个没有链接到按钮等的segue,这样我就可以以编程方式进行,或者你应该怎么做。我希望有两个视图可以根据方向动态选择,而不是在旋转时通过代码移动对象,因为有很多对象和自定义的东西可以让它更简单,只有两个视图。

How do you add a segue that either isn't linked to a button etc so I can do programatically or how are you supposed to do this. I want to have two views that get dynamically picked based on orientation rather than moving the objects based via code when rotated as there is alot of objects and custom stuff that would make it much simplier just to have two views.

推荐答案

您必须手动触发segue。将按钮连接到一个方法,然后在故事板中制作两个segues,一个从每个视图控制器到另一个,然后在IB中给它一个标识符,然后在你的方法中你可以调用performSegueWithIdentifier:。

You'd have to trigger the segue manually. Hook up the button to a method, then make two segues, one from each view controller to the other in your storyboard, then give it an identifier in IB, then in your method you can call "performSegueWithIdentifier:".

其他信息

要进行手动segue,请从IB中的视图控制器对象进行控制单击到另一个视图控制器,该框将弹出为Manual Segue。只要确保它有一个标识符。

To make a manual segue, control-click from the view controller object in IB to another view controller and the box will pop up as "Manual Segue". Just make sure it has an identifier.

这篇关于手动使用Segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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