xcode 添加滑动手势以查看故事板上的控制器不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12218140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
adding swipe gesture to view controllers on storyboard not working
提问by Muhammad Umar
I am pretty new to this so i was following this tutorial.
我对此很陌生,所以我正在关注本教程。
www.youtube.com/watch?v=5u1-DGiUhXU
I have 4 view controllers with images etc. And i have done exactly as per this video. My problem is, if i tap, drag do anything nothing happens. I am just stuck at main screen. I have tried changing push
to model
but it don't work either.
我有 4 个带有图像等的视图控制器。我完全按照这个视频做的。我的问题是,如果我点击,拖动什么都不会发生。我只是卡在主屏幕上。我尝试更改push
为,model
但它也不起作用。
Any Ideas?
有任何想法吗?
回答by Stas
You should set your imageViews UserInteractionEnabled = YES to enable touches cause it is =NO by default. Just solved similar problem this way.
您应该设置 imageViews UserInteractionEnabled = YES 以启用触摸,因为默认情况下它是 =NO。刚刚通过这种方式解决了类似的问题。
EDIT: I've just repeated the actions described in video and everything works fine! You really should follow the video guide carefuly! P.S. The swipe gesture should be a quick move from the left side of screen to the right.
编辑:我刚刚重复了视频中描述的操作,一切正常!你真的应该仔细遵循视频指南!PS 滑动手势应该是从屏幕左侧快速移动到右侧。
回答by Aerim
I saw the same tutorial and I had the same problem and i solved it as follows:
我看到了同样的教程,我遇到了同样的问题,我解决了如下问题:
When dragging the Swipe Gesture Recognizer u MUST drag it into the view itself(where the background color apears). When it wasnt working for me i was dragging it to the Black bar on the bottom. Hope this helps.
拖动滑动手势识别器时,您必须将其拖动到视图本身(背景颜色出现的位置)。当它对我不起作用时,我将它拖到底部的黑色条上。希望这可以帮助。