I have an UIScrollView
with a few subviews and so on. I am also the scrollView's delegate
and have implemented the - (void)scrollViewDidScroll:(UIScrollView *)scrollView
. Underneath my scroll there is another view.
I want to show that view if the scrollView's contentOffset
goes under 50px on x axis, "reset" scrollView's contentOffset
and cancel the current scrollView gesture so that the user wont manipulate its content when the new view appears.
I have implemented the method like so:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.x < -50)
{
scrollView.contentOffset = CGPointZero;
[self showBackView];
//here I want to cancel the current touch on the scrollview since it keeps scrolling if I drag my finger
}
}
I have tried to set the userInteractionEnabled
property to NO
but it takes effect only after the touch has ended. And I have tried a bunch of other properties but none seems to work.
How can I fix this?
Try disabling the panGestureRecognizer
for the scroll view (and then reenabling it). This will cancel the current session of the recogniser:
self.scrollView.panGestureRecognizer.enabled = NO;
self.scrollView.panGestureRecognizer.enabled = YES;
self.scrollView.panGestureRecognizer.isEnabled = false
self.scrollView.panGestureRecognizer.isEnabled = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With