在GestureRecognizer中更改UIView userInteractionEnabled不起作用

时间:2015-05-20 05:22:31

标签: ios uiview uigesturerecognizer

我想在UIPanGestureRecognizer回调期间更改UIView。例如:

- (void)handleScroll:(UIPanGestureRecognizer *)recognizer
    if (recognizer.state == UIGestureRecognizerStateBegan){
        self.subview.userInteractionEnabled = NO;
    } else if (recognizer.state == UIGestureRecognizerStateEnded){
        self.subview.userInteractionEnabled = YES;
    }
}

这在UIPanGestureRecognizer回调中从未奏效,但如果我在initWithFrame方法中编写代码

,它确实有效

我也尝试在回调中使用performSelectorOnMainThread:<#(SEL)#> withObject:<#(id)#> waitUntilDone:<#(BOOL)#>,但它都没有用。

对手势识别器回调中你不能做什么有什么限制吗?

1 个答案:

答案 0 :(得分:0)

我在UIGestureRecognizer中意外将cancelsTouchesInView设置为NO。将其更改为YES可解决问题。