0

どのリンクが押されているかを検出する方法はありますか? 「次の」VC を開くことはできますが、どの単語かを検出できないようです。これは、リンクにする必要がある単語を検出する方法です。

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];

    }
}
4

1 に答える 1

2

URL に単語を含める必要があります。したがって、 の URL を使用する代わりに、;action://atを使用できます。action://at?fooコールバックで、URL の一部を取得でき、queryそれがタップされた単語になります。

于 2013-11-24T20:20:30.630 に答える