TTTAttributedLabel can detect links,but can't be pressed correctly

倾然丶 夕夏残阳落幕 提交于 2019-12-23 12:45:42

问题


I am using TTTAttributedLabel to detect links, here is the code I init the label:

 - (TTTAttributedLabel *)getLinkLabelWithSize:(CGSize)size text:(NSString *)text{
    TTTAttributedLabel *linkLabel;
    linkLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(0, 0, size.width * 1.1, size.height)];
    linkLabel.font = [UIFont systemFontOfSize:14.0f];
    linkLabel.backgroundColor = [UIColor clearColor];
    linkLabel.lineBreakMode = UILineBreakModeWordWrap;
    linkLabel.numberOfLines = 0;
    linkLabel.enabledTextCheckingTypes = NSTextCheckingTypeLink;
    linkLabel.delegate = self;
    linkLabel.text = text;

    return linkLabel;
}

I add the label to anther view(xxxView).

CGSize size = [str sizeWithFont:fon constrainedToSize:CGSizeMake(150, 40)]; [returnView addSubview:[self getLinkLabelWithSize:size text:str]];

And here is the label delegate method:

  #pragma mark - TTTAttributedLabelDelegate
  - (void)attributedLabel:(TTTAttributedLabel *)label
   didSelectLinkWithURL:(NSURL *)url {
    [[UIApplication sharedApplication] openURL:url];
}

The problem is that I have to press the xxxView many times to open the link. It's there something wrong with my codes?

Can anyone helps me , please.


回答1:


check if there is TapGesture for your cell content view,if yes, remove Gesture from the text message cell




回答2:


Just had this issue, got really desperate when realised there is a fix in new released version



来源:https://stackoverflow.com/questions/24319763/tttattributedlabel-can-detect-links-but-cant-be-pressed-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!