When a user scrolls a certain distance horizontally beyond the contentSize of my scrollView I want to ‘take over’ and run some animations. The problem is that even if I turn off user interaction as soon as this happens, the ‘drag’ operation is still ongoing. Only when the user releases his touch is interaction disabled.
Is there a way to programmatically simulate the touch up at the end of the drag? The end result should be that when my trigger fires, the user is immediately unable to manipulate the view any more.
You could temporarily set the scrollView’s
scrollEnabledproperty toNO. (Unlike theuserInteractionEnabledproperty, togglingscrollEnabledhas immediate effect.) You can turn it back on again when your animation is done.From Apple’s documentation:
scrollEnabled
A Boolean value that determines whether scrolling is enabled.
@property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabledDiscussion
If the value of this property is YES, scrolling is enabled, and if it is NO, scrolling is disabled. The default is YES.
When scrolling is disabled, the scroll view does not accept touch events; it forwards them up the responder chain.