TTTAttributedLabel can detect links but cannot be clicked correctly

I am using TTTAttributedLabel to detect links, here is the code that I start with 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 a label to the 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 click xxxView repeatedly to open the link. Is this something wrong with my codes?

Can someone help me please.

+4
source share
2 answers

check if there is a TapGesture to view the contents of the cell; if so, remove the Gesture from the cell text message

+1
source

It’s just that this problem was very desperate when they realized that there is a fix in the new released version

0

Source: https://habr.com/ru/post/1545311/


All Articles