我有包含VC的uipageviewcontroller.与任何pageviewcontroller一样,您可以向左滑动,向右滑动以更改VC.每次动画完成后,我都会添加gestureRecognizer.我的问题是如何检查视图是否有特定的识别器?我需要这样的代码:
if check view has specific recognizer == false { add recognizer }else{ just skip. }
我这样做是因为我有侧边栏.当Sidebarmenu出现时,我想为当前索引pagecontentviewcontroller添加手势.所以,我的代码工作正常,我只是不想每次动画结束时添加手势.
我正在添加代码.问题是我的手势是在其他类(非当前)中创建的.首先,我创建了我保持手势的类实例:
let transtionManger = TransitionManger()
添加此类名为exitPanGesture的var之后:
pageContentViewController.view.addGestureRecognizer(transtionManger.exitPanGesture3)
解决方法
那是你在找什么?请参阅评论作为解释:
// If any gesture recogniser is added to the view (change view to any view you want to test) if let recognizers = view.gestureRecognizers { for gr in recognizers { // This check for UIPanGestureRecognizer but you can check for the one you need if let gRecognizer = gr as? UIPanGestureRecognizer { println("Gesture recognizer found") } } }