2012-05-16 57 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

相关问题