我有一个要画线的 View 。当我用两根或更多手指画一条线时,会出现一种奇怪的行为。这就是为什么我想在此 View 上禁用多点触控。
我试过了:
self.drawingView.multipleTouchEnabled = NO;
self.drawingView.exclusiveTouch = YES;
但是没有影响。而我的 touches 方法仍然被调用。 理想情况下,我希望当我尝试用两根手指绘图时,它什么都不做。有解决办法吗?
谢谢:)
最佳答案
在你的触摸方法(开始/移动)中检查屏幕上有多少触摸,只有一个触摸,处理它,否则传递它。 touchesMoved
示例:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if ((touches.count == 1) && ([event allTouches].count == 1)) {
// handle single finger touch moves here
....
} else {
// If more than one touch, pass it along
[super touchesBegan:touches withEvent:event];
}
关于ios - 禁用绘图 View 的多点触控,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13219876/