问题
I am successfully adding links to a UILabel
via OHAttributeLabel
and -(void)addCustomLink:(NSURL*)linkUrl inRange:(NSRange)range;
In other words, the correct range is underlined and looks like a link.
However, I cannot click/touch on the link. Is there anything else that must be done that the addCustomLink
method on the range of text? FWIW, I am not using Interface Builder even though much of the OHAttributedLabel
code makes references to IBOutlet
.
回答1:
The required code in this case was simply:
[myLabel setDelegate:self];
And in context for those interested is:
descriptionLabel.attributedText = [NSMutableAttributedString attributedStringWithString:@"foo"];
[myLabel addCustomLink:[NSURL URLWithString:urlString] inRange:NSMakeRange(myLocation, myLength)];
[myLabel setDelegate:self];
Many thanks!
来源:https://stackoverflow.com/questions/10116820/how-to-make-customlink-touchable-in-ohattributedlabel