我正在尝试使用NIAttributedLabel
生成一个既包含文字,也包含文字,链接并支持此行为的标签:
- (void)attributedLabel:(NIAttributedLabel *)attributedLabel didSelectTextCheckingResult:(NSTextCheckingResult *)result atPoint:(CGPoint)point;
- 这样可以正常工作。我不必使用NIAttributedLabel
所以建议更好的控制也可以。
感谢您的帮助
答案 0 :(得分:0)
我终于弄明白了;
将功能添加到文件NIAttributedLabel.m
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
// never return self. always return the result of [super hitTest..].
// this takes userInteraction state, enabled, alpha values etc. into account
UIView *hitResult = [super hitTest:point withEvent:event];
// don't check for links if the event was handled by one of the subviews
if (hitResult != self) {
return hitResult;
}
if (self.explicitLinkLocations || self.detectedlinkLocations) {
BOOL didHitLink = ([self linkAtPoint:point] != nil);
if (!didHitLink) {
// not catch the touch if it didn't hit a link
return nil;
}
}
return hitResult;
}
删除所有touchXXX中的所有[超级触控XXXX]功能;
然后,它有效!