Reputation: 3473
I want to implement a tagging feature in my application.
There is some text in the label on which I want to give the UIButton
action event.
I had used this code to detect whether particular text is present in the UILabel
or not.
How do I check if the particular text is present and if it gives the UIButton
action event?
arr_count = {ABC,DEF,PQR};
FOR(int i = 0; i < [arr_Count]; i++) {
Nsstring *Str_dec1;
NSRange range = [Str_dec1 rangeOfString:[arr_count objectatindex:i] options:NSCaseInsensitiveSearch];
if (range.location != NSNotFound) {
*******.....MISING CODE HERE......*****
}
}
How should I code so that it gives me the UIButton
action event when I click on ABC or PQR or DEF text in UILabel
?
Upvotes: 0
Views: 151
Reputation: 371
You could use a UITapGestureRecognizer
on the label to call the UIButton
method. Or you could do something like:
if(condition)
{
[self callButtonEvent:sender] // sender can be nil if you aren't passing anything
}
where condition
is when you check if your label's text is equal to whatever string you want.
Upvotes: 1