UIScrollview delaysContentTouches issue

前端 未结 6 2115
無奈伤痛
無奈伤痛 2020-12-13 10:33

I have UIScrollView loaded with UIButtons and on UIButton action I have highlighted UIImage of each UIButton

6条回答
  •  轮回少年
    2020-12-13 11:15

    1. Create a subclass of the UIScrollView (or UITableView, or UICollectionView, or any other UIScrollView subclass that you use).

    2. Implement the below method:

      - (BOOL)touchesShouldCancelInContentView:(UIView *)view {
      
           if ([view isKindOfClass:UIButton.class]) {
      
                return YES;
           }
      
           return [super touchesShouldCancelInContentView:view];
      }
      
    3. Set this subclass at xib/storyboard as a "Custom Class" class if you use the interface builder.

    4. Unselect Delay Touch Down in a xib or set delaysContentTouches = NO in code.

提交回复
热议问题