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 {
// ...
}