2009-02-27 11 views
3

我有以下代碼:多點觸摸沒有在iPhone應用程序工作,我要建

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 


NSUInteger touchCount = 0; 
// Enumerates through all touch objects 
for (UITouch *touchb in touches){ 
    touchCount++; 
} 


// When multiple touches, report the number of touches. 
if (touchCount > 1) { 
    lblStatustouch.text = [NSString stringWithFormat:@"Tracking %d touches", touchCount]; 
} else { 
    lblStatustouch.text = [NSString stringWithFormat:@"Tracking 1 touch", touchCount]; 
} 

當我運行它,它永遠不會檢測到多個觸摸。有一些設置可能會阻止我的應用程序進行多次觸摸嗎?或者我在這裏錯過了什麼?

回答

10

您需要啓用您的視圖「多觸摸」 InterfaceBuilder下

alt text http://img.skitch.com/20090227-rpkafsxtg56pujk1h1583if88i.jpg

,或者如果你已經創建了代碼,查看它的設置與

[theView setMultipleTouchEnabled:YES]; 
+0

謝謝你,我在代碼中創建了視圖,並試圖弄清楚它。我做到了,現在它工作得很好! – 2009-02-27 21:25:47

1

也知道你們會只有在觸摸移動時纔會觸及多個移動如果兩個手指同時移動。如果您將一根手指固定在屏幕上,然後移動另一根手指,手機將只報告正在移動的手指。

相關問題