2012-05-16 59 views
4

如何在uilabel上獲取UILongPressGestureRecognizer?當我實現下面的代碼時,它不會調用該函數。所以請告訴我我做了什麼錯誤?UILabel UILongPressGestureRecognizer不工作?

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]  initWithTarget:self action:@selector(LabelLongPressed:)]; 
longPress.minimumPressDuration = 0.5; // Seconds 
longPress.numberOfTapsRequired = 0; 

[objlblDuplicate addGestureRecognizer:longPress]; 
[longPress release]; 

回答

18

默認情況下,UILabel無法獲取觸摸事件。

objlblDuplicate.userInteractionEnabled = YES; 
+0

Thankyou @adali現在工作正常 – Vicky

+0

LongPressedGesture雖然被認可了兩次。第一次是長按發生,第二次是長按從手指放開。 – coolcool1994

相關問題