UIButton touch is delayed when in UIScrollView

UIButton touch is delayed when in UIScrollView

解决UIButton的touch事件在 UIScrollView中延迟的情况:


Try to set UIScrollView delaysContentTouches property to NO.


_scrollView.delaysContentTouches = NO;   //延迟


[button addTarget:self action:@selector(changeButtonBackGroundColor:) forControlEvents:UIControlEventTouchDown];



-(void)changeButtonBackGroundColor:(UIButton*) sender{
    NSLog(@"changeButtonBackGroundColor...");
    if ([sender.backgroundColor isEqual:[UIColor clearColor]]){
        UIImage *image = [self mergeBackgroundImage];
        [sender setBackgroundColor:[UIColor colorWithPatternImage:image]];
    }else{
        [sender setBackgroundColor:[UIColor redColor]];
    }
}



猜你喜欢

转载自zl4393753.iteye.com/blog/1781669