#pragma mark - 点击各个点赞用户
-(void)setClicked:(TweetCell *)cell andOSCTweet:(OSCTweet *)tweet
{
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tweet.likeListString];
//遍历每个点赞用户的名称
for (int i = 0; i < 3 && i < tweet.likeCount; i++){
OSCUser *user = tweet.likeList[i];
NSRange nameRange = [tweet.likeListString rangeOfString:user.name];
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor nameColor] range:nameRange];
[cell.likeListLabel addLinkToURL:[NSURL URLWithString:[NSString stringWithFormat:@"userid:%lld", user.userID]] withRange:nameRange];
}
NSRange numRange = [tweet.likeListString rangeOfString:[NSString stringWithFormat:@"%d人", tweet.likeCount]];
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor nameColor] range:numRange];
[cell.likeListLabel addLinkToURL:[NSURL URLWithString:[NSString stringWithFormat:@"tweetid:%lld", tweet.tweetID]] withRange:numRange];
cell.likeListLabel.attributedText = attributedString;
cell.likeListLabel.delegate = self;
}
#pragma mark - TTTAttributedLabelDelegate
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url
{
NSArray *arrayStr = [url.absoluteString componentsSeparatedByString:@":"];
if ([arrayStr[0] isEqualToString:@"userid"]) {
UserDetailsViewController *userDetailsVC = [[UserDetailsViewController alloc] initWithUserID:((NSNumber *)arrayStr[1]).longLongValue];
[self.navigationController pushViewController:userDetailsVC animated:YES];
} else {
TweetsLikeListViewController *likeListCtl = [[TweetsLikeListViewController alloc] initWithtweetID:((NSNumber *)arrayStr[1]).longLongValue];
[self.navigationController pushViewController:likeListCtl animated:YES];
}
}
转载于:https://my.oschina.net/pingAds/blog/416401