0

我正在开发类似于 Vine Application 的应用程序,在该注释单元格中提供导航(@User 存在或#tag 存在),如果用户或标签不存在,则该导航完全有效。

如果有人知道,如何做到这一点,请给我参考或建议(请不要给出任何建议,比如如果用@或#找到单词,然后给出我已经做过的字符串属性,但我想要的正是副评论单元格)

您也可以提出一些想法或建议。

谢谢是提前。

4

1 回答 1

1

You can use TTTAttributedLabel. It will help you to provide link action. Implement it as follows

TTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:frame];
[label setAttributedText:@"yourText"];
label.delegate = self;
label.enabledTextCheckingTypes = NSTextCheckingTypeLink;
[label addLinkToURL:url withRange:range];
[yourCell.contentView addSubview:label];

and you can capture the link action in:

- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url

which is the TTTAttributedLabelDelegate method. Don't forget to add TTTAttributedLabelDelegate in the interface file.

于 2014-03-21T08:13:25.567 回答