首先导入第三方类:NSMutableString+TagReplace 、NSString+WPAttributedMarkup 、 WPAttributedStyleAction 、WPTappableLabel 、WPHotspotLabel (文件见百度云盘)
第一种情况: (谁回复谁)
NSDictionary* style3 = @{@"body":[UIFont fontWithName:@"HelveticaNeue" size:12.0],
@"author":[WPAttributedStyleAction styledActionWithAction:^{
NSLog(@"author action");
NSString *author = [tempautorInfo objectForKey:@"userId"];
[self tapCommentType1:author];
}],
@"toauthor":[WPAttributedStyleAction styledActionWithAction:^{
NSLog(@"toauthor action");
NSString *toauthor = [toAuthorInfo objectForKey:@"userId"];
[self tapCommentType1:toauthor];
}],
@"link": [UIColor orangeColor]};
NSString *authorName = [tempautorInfo objectForKey:@"nickName"];
NSString *toauthor = [toAuthorInfo objectForKey:@"nickName"];
if ([[[UserInfoDB defaultManger] getUserInfo:@"userId"] isEqualToString:[toAuthorInfo objectForKey:@"userId"]] == YES) {
toauthor = @"我";
}else{
toauthor = [toAuthorInfo objectForKey:@"nickName"];
}
NSString *reply = [NSString stringWithFormat:@"<author>%@</author>回复 <toauthor>%@</toauthor>",authorName,toauthor];
cell.replyLabelName.attributedText = [reply attributedStringWithStyleBook:style3];
第二种情况(谁评论的)
NSDictionary* style3 = @{@"body":[UIFont fontWithName:@"HelveticaNeue" size:12.0],
@"author":[WPAttributedStyleAction styledActionWithAction:^{
NSLog(@"author action");
NSString *author = [tempautorInfo objectForKey:@"userId"];
[self tapCommentType0:author];
}],
@"toauthor":[WPAttributedStyleAction styledActionWithAction:^{
NSLog(@"toauthor action");
NSString *toauthor = [toAuthorInfo objectForKey:@"userId"];
[self tapCommentType0:toauthor];
}],
@"link": [UIColor orangeColor]};
NSString *reply = [NSString stringWithFormat:@"<author>%@</author>" ,[tempautorInfo objectForKey:@"nickName"]];
cell.replyLabelName.attributedText = [reply attributedStringWithStyleBook:style3];
NSDictionary* style3 = @{@"body":[UIFont fontWithName:@"HelveticaNeue" size:12.0],
@"author":[WPAttributedStyleAction styledActionWithAction:^{
NSLog(@"author action");
NSString *author = [tempauthorInfo objectForKey:@"userId"];
[self tapCommentType1:author];
}],
@"toauthor":[WPAttributedStyleAction styledActionWithAction:^{
NSLog(@"toauthor action");
NSString *toauthor = [commentPosts objectForKey:@"userId"];
[self tapCommentType1:toauthor];
}],
@"link": [UIColor orangeColor]};
NSString *authorName = [tempauthorInfo objectForKey:@"nickName"];
NSString *reply = [NSString stringWithFormat:@"<author>%@</author>赞了",authorName];
cell.replyLabelName.attributedText = [reply attributedStringWithStyleBook:style3];
- (void)tapCommentType1:(NSString *)userId
{
DBLog(@"进入点赞的人的个人资料");
UserInfoViewController *userInfoVC = [[UserInfoViewController alloc] init];
// userInfoVC.userId = [NSString stringWithFormat:@"%ld", btu.tag - 3000];
userInfoVC.userId = userId;
DBLog(@"---userId=%@", userInfoVC.userId);
[self presentViewController:userInfoVC animated:YES completion:^{
}];
}