2

我想要一个正常的UINavigationController回扫式手势在基本上是UIWebView浏览器的视图控制器上工作。默认情况下,UIWebView似乎不允许识别UINavigationController向后滑动手势。UINavigationController中的UIWebView是否允许识别iOS 7轻扫式内置手势?

如果我将UIWebView.delegate设置为我的视图控制器,并添加下面的方法,它将正确识别UINavigationController's反向滑动。

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { 
    return YES; 
} 

但是完成该手势(其弹出UIWebView's视图控制器)后,当我做另一手势它崩溃。 (下面的堆栈跟踪。)通过“其他手势”,我的意思是简单地滚动浏览控制器上的UIWebView,我在刷卡后弹出。

问题总是YES返回值搞乱了UIWebView手势的正常交互吗?看起来我只想让导航手势始终为YES,但是我希望webview手势可以做任何他们通常做的事情,但我不能仅仅拨打[super gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]来获得该行为。坦率地说,我很惊讶UIWebView委托被发送到手势回调。

Thread 1, Queue : com.apple.main-thread 
#0 0x3a80cb66 in objc_msgSend() 
#1 0x32e23f9a in -[UIGestureRecognizer _delegateCanPreventGestureRecognizer:]() 
#2 0x32cce418 in -[UIGestureRecognizer _isExcludedByGesture:]() 
#3 0x32c9410e in _UIGestureRecognizerUpdate() 
#4 0x32ccd1b4 in -[UIWindow _sendGesturesForEvent:]() 
#5 0x32cccb62 in -[UIWindow sendEvent:]() 
#6 0x32ca1f58 in -[UIApplication sendEvent:]() 
#7 0x32ca0746 in _UIApplicationHandleEventQueue() 
#8 0x304e2f26 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__() 
#9 0x304e23ee in __CFRunLoopDoSources0() 
#10 0x304e0bde in __CFRunLoopRun() 
#11 0x3044b540 in CFRunLoopRunSpecific() 
#12 0x3044b322 in CFRunLoopRunInMode() 
#13 0x351822ea in GSEventRunModal() 
#14 0x32d021e4 in UIApplicationMain() 
#15 0x000df478 in main at /path/to/main.m:17 
#16 0x000df398 in start() 

回答

5

我刚刚遇到了同样的问题(但我有正规的UIViewController代替 - MWPhotoBrowser - 在某些原因还封锁这一系统回退姿势),我在viewWillDisappear:处理程序中设置

self.navigationController.interactivePopGestureRecognizer.delegate = nil; 

解决它。希望能帮助到你。