I am trying to determine if a UILabel was touched and if so do something. Give ..
.
.
.
UILabel * site = [[UILabel alloc] initWithFrame:CGRectMake(0, 185, 32
Eugene's solution works but you must have "user interaction enabled" ticked in your NIB file. Or as Mahyar has with the label.userInteractionEnabled = YES.
Here is my solution as I had two seperate labels that I wanted to capture touches from. And I have "user interaction enabled" ticked in my nib file.
UITapGestureRecognizer *theSpeedTapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
[speedLabel addGestureRecognizer:theSpeedTapped];
UITapGestureRecognizer *theDirectionTapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
[directionLabel addGestureRecognizer:theDirectionTapped];
I hope this helps.