我想停止滚动后,发现第二次触摸和处理触摸与我自己的捏手势。
我在滚动视图中尝试过:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if(event.allTouches.count > 2)self.panGestureRecognizer.enabled = NO;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(event.allTouches.count > 2)self.panGestureRecognizer.enabled = YES;
}
但没用。
试试这个:
scroll.panGestureRecognizer.maximumNumberOfTouches = 1;
但什么都没有
最佳答案
我找到了解决办法。我重新定义了uiscrollview,并添加:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
以及禁用/启用平移手势:
if(pinch.state == UIGestureRecognizerStateBegan) scroll.panGestureRecognizer.enabled = NO;
if(pinch.state == UIGestureRecognizerStateEnded) scroll.panGestureRecognizer.enabled = YES;
现在我的捏手动作生效了。
关于objective-c - 禁用两指捏住UIScrollView中的平移,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13988532/