On iOS 7.
I have navigation controller and I push a new VC on top of the stack.
That new VC has a UIScrollView that fills the VC’s root view and scrolls vertically. If I scroll down a little bit and then try to use ‘swipe to go back’ / ‘swipe to pop’ gesture, the vertical scroll view first scrolls to top, and then the interactivePopGesture is recognized and I can drag the top VC on the stack left and right.
Why does this happen?
I wish to prevent my scroll view from automatically scrolling to the top before ‘swipe to go back’ gesture is recognized.
How do I do this?
I cannot seem to reproduce this bug when I create a fresh xcode project, so it is most certainly error on my part in the original project. Will update when I find the reason.
When interactivePopGesture gets recognized,
setContentOffset method is called on my vertical scroll view. While debugging, I see that
setContentOffset was invoked from
Same problem happens in a following scenario:
I have UITextFields inside a vertical UIScrollView. When a certain UITextField is pressed, a keyboard appears. When I want to dismiss the keyboard interactively (by dragging on scroll view over the keyboard), after I release the drag, a glitch happens. UIScrollView’s content offset has momentarily been set to zero, and then set back to original content offset and proceeded with the animation. This unwanted setting of
contentOffset is also invoked by
I went ahead and replaced the UIScrollView in both scenarios with my own subclass of UIScrollView. In that subclass I overridden a private method
-(void) _adjustContentOffsetIfNecessary as a empty void method. Both of my problems were eliminated, and I could not find any negative consequences. This is not a solution and I will not use this approach, since I have no idea what exactly I have done.
Source: Ios7 Questions