I want the normal UINavigationController
swipe-back-to-pop gesture to work on a view controller that is basically a UIWebView
browser. By default it seems that the UIWebView doesn't allow the UINavigationController
swipe-back gesture to be recognized.
If I set the UIWebView.delegate
to my view controller, and add the below method, it will recognize the UINavigationController's
back-swipe correctly.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
But after completing that gesture (which pops the UIWebView's
view controller), when I do another gesture it crashes. (Stack trace below.) And by "other gesture" I mean simply scrolling a UIWebView
on the view controller I popped to after the swipe.
Is the problem that the always YES
return value is messing up the normal interaction of the UIWebView gestures? It seems like I want to only allow the navigation gesture to always be YES, but then I want the webview gestures to do whatever they do normally, but I can't just call [super gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]
to get that behavior. Frankly I was surprised that the UIWebView delegate was being sent the gesture callbacks at all.
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 ()