2013-02-07 60 views
0

同時數在我UIView小類我有這樣的:無法檢索觸摸

- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event 
{ 
    UITouch* touch = [touches anyObject]; 
    CGPoint location = [touch locationInView: self]; 
    NSLog(@"touches count: %i",[touches count]); //always shows 1 
} 

無論我有多少手指觸摸屏幕後,我只得到「1」作爲輸出。我還在touchesMoved上添加了上面的結果。

回答

1

您是否啓用了多點觸控選項?

[(your uiview) setMultiTouchEnabled:YES]; 

這是默認爲false,將所有觸摸視圖轉換爲所有其他觸摸中的一次觸摸。

將其設置爲YES會讓你的觀點收到一個觸摸事件在屏幕上的每個手指(或筆)

+0

勝利者去了第一響應者,謝謝。這是我錯過的。我會盡快接受這個答案。 – johnbakers

+0

順便說一句,與「第一響應者」,沒有雙關語意圖! – johnbakers

+1

沒問題,這讓我在這裏發笑 –

1

我覺得有一個「啓用多點觸摸」複選框,在Interface Builder等等。還有一個對應的屬性你可以設置。