简体   繁体   English

如何使用手势快速iOS过渡到视图控制器

[英]How to transition to a view controller with gesture swift iOS

I have a problem with implementing a button which should redirect my current view to another view when tapping on it. 我在实现按钮时遇到问题,点击该按钮时应将当前视图重定向到另一个视图。 I have a central view and I already implement the gestures on top, left and right to move to others views. 我有一个中心视图,并且已经在顶部,左侧和右侧实现了手势以移动到其他视图。

But on this central view I want to add a button that allows me to redirect towards my right screen without using gesture from right to left with my finger. 但是在此中央视图上,我想添加一个按钮,使我无需使用手指从右到左的手势即可重定向到右侧屏幕。

I added an IBOutlet action for this button, but I do not know what method to implement for switching back to my right screen (not the top or left screen). 我为此按钮添加了IBOutlet操作,但我不知道要实现哪种方法来切换回我的右屏幕(而不是顶部或左侧屏幕)。

If anyone can help me thank you very much! 如果有人可以帮助我,非常感谢!

If you create a segue in Interface Builder and give it an identifier. 如果在Interface Builder中创建序列并为其提供标识符。 You can then perform this segue (what you call "a transition" ) by calling 然后,您可以通过调用以下命令执行此命令(称为“过渡”

performSegue(withIdentifier: <String>, sender: self)

Of course you will need to replace <String> with your segue's identifier 当然,您需要将<String>替换为segue的标识符


  • One can create a segue by control dragging from one view controller to another view controller 可以通过控制从一个视图控制器拖到另一个视图控制器来创建序列
  • One can give a segue an identifier by 一个人可以给segue一个标识符
    1. clicking on the just created segue (this is a line between the view cotrollers in the storyboard) 单击刚刚创建的segue(这是情节提要中的视图控制者之间的一条线)
    2. opening the Attributes Inspector (press: alt cmd 4 or click on: View > Utilities > Show Attributes Inspector) 打开属性检查器(按: alt cmd 4或单击:视图>实用程序>显示属性检查器)
    3. filling in the textfield next to the label "Identifier" 填写标签“标识符”旁边的文本字段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM