Есть ли способ определить, какая ссылка нажата? Я могу открыть «следующий» VC, но я не могу определить, какое слово. Вот как я определяю, какие слова должны быть ссылками:TTTAttributedLabel обнаруживает несколько ссылок
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];
}
}
Вот метод для ссылки ссылка:
- (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];
}
}
С вашей помощью и некоторыми настройками он работает. Спасибо! – hugocarlmartin