UILabel有触摸方法吗? [英] Is there a touch method for UILabel?
本文介绍了UILabel有触摸方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果有人碰到预先声明的 UILabel
,我想采取行动:
I'd like to do an action if someone touches a predeclared UILabel
, something like:
if (label is touched) {
my actions;
}
是否有方法/方法?
推荐答案
您可以使用手势识别器:
You could use a gesture recognizer:
- (void)someSetupMethod {
// ...
label.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = \
[[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(didTapLabelWithGesture:)];
[label addGestureRecognizer:tapGesture];
[tapGesture release];
}
- (void)didTapLabelWithGesture:(UITapGestureRecognizer *)tapGesture {
// ...
}
这篇关于UILabel有触摸方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文