UILabel UILongPressGestureRecognizer无法正常工作?

时间:2012-05-16 06:28:10

标签: iphone ios uibutton uigesturerecognizer

如何在uilabel上获得UILongPressGestureRecognizer。当我实现以下代码时,它不会调用该函数。请告诉我我做错了什么?

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

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

1 个答案:

答案 0 :(得分:20)

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

objlblDuplicate.userInteractionEnabled = YES;