5

我怎样才能获得UILongPressGestureRecognizeruilabel。当我实现以下代码时,它不会调用该函数。所以请告诉我我做错了什么?

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

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

1 回答 1

24

默认情况下,UILabel 无法获取触摸事件。

objlblDuplicate.userInteractionEnabled = YES;
于 2012-05-16T06:30:41.183 回答