【问题标题】:Can a UIWebView in a UINavigationController allow the iOS 7 swipe-to-pop built-in gesture to be recognized?UINavigationController 中的 UIWebView 能否允许识别 iOS 7 滑动弹出内置手势?
【发布时间】:2014-02-17 10:12:31
【问题描述】:

我希望普通的UINavigationController swipe-back-to-pop 手势在基本上是UIWebView 浏览器的视图控制器上工作。默认情况下,UIWebView 似乎不允许识别UINavigationController 向后滑动手势。

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

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

但是在完成那个手势(弹出UIWebView's 视图控制器)之后,当我做另一个手势时它崩溃了。 (下面的堆栈跟踪。)“其他手势”是指在滑动后弹出的视图控制器上滚动UIWebView。

总是YES的返回值是不是搞乱了UIWebView手势的正常交互?似乎我只想让导航手势始终为“是”,但随后我希望 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 ()

【问题讨论】:

    标签: ios ios7 uiwebview uinavigationcontroller uigesturerecognizer


    【解决方案1】:

    我刚刚遇到了同样的问题(但我有常规的 UIViewController - MWPhotoBrowser - 由于某种原因也阻止了这个系统返回手势),我通过设置解决了它

    self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    

    在viewWillDisappear: 处理程序中。希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 2013-06-17
      • 1970-01-01
      相关资源
      最近更新 更多