2012-11-04 62 views
0

我有一個觀點,我正在畫線。當我用兩根或更多的手指畫線時,會出現奇怪的行爲。這就是爲什麼我想在這個視圖上禁用多點觸摸的原因。禁用多觸摸的圖紙視圖

我想:

self.drawingView.multipleTouchEnabled = NO; 
self.drawingView.exclusiveTouch = YES; 

但沒有影響。而我的觸摸方法仍然被稱爲。 理想情況下,我想,當我嘗試用兩個手指畫,它什麼都不做。有解決方案嗎?

謝謝:)

回答

2

在你觸摸的方法(開始/移動的)檢查有多少接觸是在屏幕上只有一個觸摸,處理它,否則一起傳遞。例如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]; 

} 

}

+0

這聽起來很完美! – seb