UIButton touch is delayed when in UIScrollView

前端 未结 7 1542
遥遥无期
遥遥无期 2020-11-30 19:01

I\'m running into a small issue in my app.

I essentially have a series of UIButtons added as subviews in a UIScrollView which is part of a

7条回答
  •  情深已故
    2020-11-30 19:27

    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;
        }
    

提交回复
热议问题