Is there a way to detect which link being pressed? I can open the "next" VC but I can't seem to detect which word. This is how I detect which words should be links:
NSArray *words = [cell.lblDescription.text componentsSeparatedByString:@" "];
for (NSString *word in words) {
if ([word hasPrefix:@"@"]) {
at = [cell.lblDescription.text rangeOfString:word];
[cell.lblDescription addLinkToURL:[NSURL URLWithString:@"action://at"] withRange:at];
}else if ([word hasPrefix:@"#"]) {
hash = [cell.lblDescription.text rangeOfString:word];
[cell.lblDescription addLinkToURL:[NSURL URLWithString:@"action://hash"] withRange:hash];
}
}
Here is the method for the link link:
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
if ([[url scheme] hasPrefix:@"action"]) {
if ([[url host] hasPrefix:@"hash"]) {
/* load help screen */
UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"viewTags" bundle:nil];
OIOI_VC_ViewTags *viewController =[storyboard instantiateViewControllerWithIdentifier:@"viewTags"];
viewController.str_word = ??????;
[self.navigationController pushViewController:viewController animated:YES];
}
}
You should include the word in the URL. So, instead of using a URL of action://at
, you could use action://at?foo
; in your callback, you can get the query
part of the URL and that will be the tapped word.