我有一个NStextView,它从JSON源加载描述。每次用户单击按钮时,NSTextView都会加载不同的字符串。这些描述有时会在其中包含一个URL,该URL以纯文本形式呈现,而不是可点击的URL。它加载得很好,只是URL无法识别。我设置自动链接检测无济于事。我也尝试过无法使用的AttributedString,但这可能是我的无能(对此我不熟悉。)
以下是代码:
if ([firstCommenter isEqualToString:playerID]) {
NSString *commentBody = [[allComments objectAtIndex:0] valueForKeyPath:@"body"];
[shotDescriptionTextView setString:commentBody];
}
答案 0 :(得分:0)
答案 1 :(得分:0)
更好的解决方案,无需任何类别look here
TL; DR:
[shotDescriptionTextView setEditable:YES];
[shotDescriptionTextView checkTextInDocument:nil];
[shotDescriptionTextView setEditable:NO];