views:

52

answers:

2

Hi All, I'm running into a small issue in my app.

I essentially have a series of UIButtons added as subviews in a scrollview which is part of a nib. Every time I tap on a button there is a noticeable delay before the button is highlighted. I essentially have to hold it for about half a second before the button dims and appears selected.

I'm assuming this is because the scrollview needs to determine if the touch is a scroll or if it's a touch that is meant for a subview.

Anyways, I'm a little unsure on how to proceed. I simply want the button to appear selected as soon as I tap it.

Any help is appreciated!

edit:

I've tried setting delaysContentTouches to NO but scrolling becomes almost impossible since a majority of my scrollView is filled with UIButtons.

+2  A: 

Try to set UIScrollView delaysContentTouches property to NO.

Vladimir
Sorry I probably should've been more clear. If I set delaysContentTouches to NO the touch responds immediately. However, scrolling pretty much becomes impossible since touches are interpreted as button presses rather than actual scrolling.
Jeff
+1  A: 

Ok I've solved this by subclassing UIScrollView and overriding touchesShouldCancelInContentView

Now my UIButton that was tagged as 99 highlights properly and my scrollview is scrolling!

myCustomScrollView.h

@interface myCustomScrollView : UIScrollView  {

}

@end

and myCustomScrollView.m

@implementation myCustomScrollView

    - (BOOL)touchesShouldCancelInContentView:(UIView *)view
    {
        NSLog(@"touchesShouldCancelInContentView");

        if (view.tag == 99)
            return NO;
        else 
            return YES;
    }
Jeff