【发布时间】:2016-10-12 09:17:32
【问题描述】:
在我的项目中,我已将 TTTAttributedLabel 添加到 IB 的视图中并添加了一个链接。
我已经查看了关于 SO 的类似问题(例如 this 和 this),但没有运气。
它显示正确,链接的样式符合预期。但是当我尝试点击链接时,没有调用-(void)attributedLabel:didSelectLinkWithURL:。但是,如果我使用长按而不是 -(void)attributedLabel:didLongPressLinkWithURL:atPoint: 按预期触发。所以我确定代表正在工作。似乎标签甚至没有tapGestureRecognizer
(lldb) po label.gestureRecognizers
<__NSSingleObjectArrayI 0x60800000ee60>(
<UILongPressGestureRecognizer: 0x7f88f6c5d480; state = Began; view = <TTTAttributedLabel 0x7f88f6f8ada0>; target= <(action=longPressGestureDidFire:, target=<TTTAttributedLabel 0x7f88f6f8ada0>)>>
)
代码如下:
RFStaticAttributedLabelFormView *labelView = [RFStaticAttributedLabelFormView new];
labelView.staticLabel.userInteractionEnabled = YES;
labelView.staticLabel.delegate = self;
NSString *text = RFLocalized(@"TXT_FINES_SEARCH_FNS");
[labelView.staticLabel setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:nil];
NSRange r = [text rangeOfString:RFLocalized(@"TXT_FINES_SEARCH_FNS_LINK")];
[labelView.staticLabel addLinkToURL:[NSURL URLWithString:@"http://www.google.com"] withRange:r];
RFStaticAttributedLabelFormView 是一个视图,从 XIB 实例化。
不知道从这里去哪里。
【问题讨论】:
标签: ios uigesturerecognizer tttattributedlabel