Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel UILongPressGestureRecognizer not working?

How can I get the UILongPressGestureRecognizer on uilabel.when i implement the following code it doesn't call the function. So please tell me what wrong i did ?

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

[objlblDuplicate addGestureRecognizer:longPress];
[longPress release];
like image 345
Vicky Avatar asked May 16 '12 06:05

Vicky


1 Answers

By default UILabel is not able to get touch events.

objlblDuplicate.userInteractionEnabled = YES;
like image 67
adali Avatar answered Oct 04 '22 20:10

adali