如何在uilabel上获得UILongPressGestureRecognizer
。当我实现以下代码时,它不会调用该函数。请告诉我我做错了什么?
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(LabelLongPressed:)];
longPress.minimumPressDuration = 0.5; // Seconds
longPress.numberOfTapsRequired = 0;
[objlblDuplicate addGestureRecognizer:longPress];
[longPress release];
答案 0 :(得分:20)
默认情况下,UILabel无法获取触摸事件。
objlblDuplicate.userInteractionEnabled = YES;