By Mike M

2014-09-12 03:36:39 8 Comments

I have a horizontal scroll view with a line of buttons. The scroll view will not scroll unless I do an extremely fast swipe.

If I set the buttons to userInteractionEnabled = NO, then the scrolling works as expected, but of course, then the buttons don't work at all.

This app worked fine in iOS 7 and before. It seems to be a iOS 8 "feature". I did notice that I can catch the button's drag event, but I don't know how to redirect it back to the scrollView.

I'm thinking I'll need to replace my buttons with UIViews and manage the events myself but I'd be grateful if someone has other ideas or solutions.


@Urmi 2014-09-24 12:08:25

I have same issue and I solved it by creating a subclass of UIScrollView and set it's cancelContentTouches value to TRUE and its working fine.

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
       return YES;

Hope it will work for you.

@Daniel Åkesson 2014-09-18 08:14:34

I've had this problem with a UITableView which has custom UITableViewCells with UIButtons on it. I put this in my UITableview class.

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
    return YES;

Solved my problem.

EDIT: Just to clearify, you can create a subclass of UIScrollview and add this to solve the problem.

@Scotty 2014-09-21 09:11:55

This one seems to be the right solution. Tried the touchedShouldBegin: method and had issues consistently recognising the button tap (as mentioned by Leonardo)

@Haitao Li 2014-09-21 22:54:09

This also worked for me.

@Robert Mao 2014-09-21 23:11:18

This is the best solution.

@Inertiatic 2014-10-01 23:13:34

Saved me a huge headache, thank you! This worked for iOS 5.1 and up.

@HotJard 2015-01-21 09:15:18

iOS 8 - not working

@lifjoy 2014-09-22 20:12:01

I found that in iOS 8, the UIScrollView's underlying UIPanGestureRecognizer is not respecting the UIScrollView's delaysContentTouches property. I consider this an iOS 8 bug. Here's my workaround:

theScrollView.panGestureRecognizer.delaysTouchesBegan = theScrollView.delaysContentTouches

@Igor Kulagin 2014-09-25 16:32:00

Fix works, but there is a problem: "highlighted" button image is not displayed when user puts finger in button.

@Zeropointer 2014-09-30 11:31:23

Thank's that work for me.

@cire.boroguies 2014-10-24 13:01:17

Save my day, thanks

@morroko 2015-04-09 14:06:23

I really appreciate for your answer.

@FurloSK 2015-07-19 10:55:59

Definitely the clearest solution I have seen yet… thanks!

@SKYnine 2015-07-19 18:19:09

You ended up so much search! thanks

@daidai 2014-09-21 04:13:11

This hack works for me:

UITapGestureRecognizer *nothingTap = [[UITapGestureRecognizer alloc] init];
nothingTap.delaysTouchesBegan = YES;
[_scrollView addGestureRecognizer:nothingTap];


@Wirsing 2014-09-22 11:21:56

Thank you! Works like a charm - and saved my day!!

@Inertiatic 2014-10-01 23:12:40

This works if you don't have to support iOS 5.1. The solution from Daniel worked across the board for me.

@Leandros 2014-10-08 07:37:20

The only solution, that actually worked for me. Interesting.

@HotJard 2015-01-21 09:20:06

Nice works. iOS 7 & 8

@Ben Kane 2014-09-17 21:46:15

I made a subclass of UIScrollView to fix this issue. You only need this method in it:

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
    UITouch *touch = [touches anyObject];

    if(touch.phase == UITouchPhaseMoved)
        return NO;
        return [super touchesShouldBegin:touches withEvent:event inContentView:view];

Then just remember to set the class to your subclass in the storyboard if you're using one and you're good to go.

@ethanneff 2014-09-18 07:02:51

This fixed my issue. Thanks!

@Mickaël 2014-09-18 11:14:57

Fixed mine too -- with a UISegmentedControl embedded in the scroll view. Many thanks!

@Leonardo 2014-09-18 17:52:43

I tried that, and it fixed the UIScrollView, but sometimes my buttons aren't responding on the first touch, did anyone else noticed that same behavior?

@daidai 2014-09-21 04:03:47

@Leonardo yep, noticing the same thing - so the solution above doesnt really solve the problem. Might have to, annoyingly, change all the buttons to views.

Related Questions

Sponsored Content

1 Answered Questions

Horizontal pan gesture inside UIScrollView

1 Answered Questions

UIScrollView Button Tap Not Working

3 Answered Questions

1 Answered Questions

Prevent UIScrollView scrolling while subview is dragged

2 Answered Questions

1 Answered Questions

1 Answered Questions

1 Answered Questions

[SOLVED] ios uiscrollview delayscontenttouches only for vertical swipe

0 Answered Questions

Is there any method forwarding event from UIButton to UIScrollView?

Sponsored Content