Search code examples
ios5xcode4.2

Click event for a particular word from a sentence


Can we give click event for a particular word from a sentence. For example, let my label be 'myLabel.text = @"contact [email protected]";'. I want to give click event for [email protected]. Is it possible in IOS5/IOS6.

Thanks in advance.


Solution

  • In iOS5/6 there's a link detection system that will pick out links from a string, however it's not available in UILabel. If you can get away with using a UITextView then it'll work perfectly, if you desperately, definitely need a UILabel you'll need to work around it slightly and use something like TTTAttributedLabel or follow a similar approach and build your own UILabel replacement.