UILabel UILongPressGestureRecognizer无法正常工作? [英] UILabel UILongPressGestureRecognizer not working?

查看:118
本文介绍了UILabel UILongPressGestureRecognizer无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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];


推荐答案

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

By default UILabel is not able to get touch events.

objlblDuplicate.userInteractionEnabled = YES;

这篇关于UILabel UILongPressGestureRecognizer无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆