Looking at the UITextViewDelegateprotocol , a new method to iOS7: textView:shouldInteractWithURL:inRange:.
, , attributedString range, , . , username.
.
[attributedString addAttribute:NSLinkAttributeName
value:[@"username://" stringByAppendingString:username]
range:range];
- :
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
if ([URL.scheme isEqualToString:@"username"]) {
[self doSomethingWithUserName:URL.host];
return NO;
}
return YES;
}
, " " WWDC 2013.