I just updated to xCode 6 and iOS 8 and I noticed something very weird with my app. In my app I have a scrollview with several buttons within it, aligned horizontally. I set it up to create my own custom scrollable tab bar controller. Before the update to iOS 8 and xCode 6 everything was working perfect, but now I realized that when I try to scroll the scrollview left or right, and my initial touch was within one of the buttons in the scroll view, then no scrolling happens. However if I touch in-between the buttons then scrolling works as expected. I think it's some issue where the button is registering the touch and it is as if the scrollview never got touched. But this was 100% working before perfectly so i do not what is going on!!
Asked
Active
Viewed 2,349 times
2
-
Just for anyone googling here. I had a weird one where, updating to XCode6, for some reason it TURNED OFF (!) "User Interaction Enabled" on a view, in Storyboard. Who knows why! I turned it on and all was well. – Fattie Sep 26 '14 at 16:21
3 Answers
3
I ended up creating a subclass of UIScrollView and set it's cancelContentTouches value to TRUE and my problem was solved

Mike Simz
- 3,976
- 4
- 26
- 43
-
-
2I think you mean this method -(BOOL)touchesShouldCancelInContentView:(UIView *)view – rozochkin Sep 17 '14 at 11:51
-
1There is no `cancelContentTouches`. Do you mean `canCancelContentTouches`? I set it to `YES` and it still didn't work for me. – Moe Salih Sep 20 '14 at 00:13
-
1As rozochkin said, overriding `(BOOL)touchesShouldCancelInContentView:(UIView *)view` and returning `YES` fixes the problem. Seems strange that you have to subclass `UIScrollView` to get this basic behaviour to work. – Moe Salih Sep 20 '14 at 00:36
1
Subclassing UIScrollView and adding code below into .m file, did solve my scrolling freeze problem under iOS 8.
Code:
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
{
UITouch *touch = [touches anyObject];
if(touch.phase == UITouchPhaseMoved)
{
return NO;
}
else
{
return [super touchesShouldBegin:touches withEvent:event inContentView:view];
}
}
This solution was found in pasta12's answer https://stackoverflow.com/a/25900859/3433059
-
Adding this solution to the other given solutions was required in my case. – Joel Aug 14 '17 at 22:32
0
No need to subclass ScrollView Just use this :
yourScrollView.panGestureRecognizer.delaysTouchesBegan =yourScrollView.delaysContentTouches;

josliber
- 43,891
- 12
- 98
- 133

gaurav bhardwaj
- 41
- 4