Is there a way to stop a UIScrollView
from scrolling while a touch is still held down? Setting the content offset using the scrollViewDidScroll:
delegate method is excessive and can cause some issues (view moves and resets quickly) with the GPU, so I was hoping for a cleaner solution, if there is one.
Asked
Active
Viewed 2,175 times
0

RileyE
- 10,874
- 13
- 63
- 106
2 Answers
2
You can simply turn it out by using its property scrollEnabled in viewDidLoad..
self.myScrollView.scrollEnabled = NO;

A R
- 461
- 4
- 14
-
Please note: "during touch" – RileyE Jan 02 '14 at 18:44
0
I would try:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[scrollView setScrollingEnabled:NO];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[scrollView setScrollingEnabled:NO];
}
That will turn it off for a press and you can adjust detecting how far the "Move" was from the original touch to see if you want to reenable scrolling or not

Chip Snyder
- 418
- 3
- 13
-
That will only work when the view is touched. I'm asking about while the view currently being touched. – RileyE Jul 08 '13 at 19:05
-
ah ok I was thinking the touches began still triggered on a long touch my bad. – Chip Snyder Jul 08 '13 at 19:40
-
It only triggers when the touches being, are moved or are ended. However the `setScrollingEnabled:NO` will also cause the jittery animation when the view moves before disabling. This doesn't have anything to do with long touches. Thank you for the response! – RileyE Jul 08 '13 at 19:45