我正在以编程方式设置 NSTextView:
NSTextView *infoTextView = [[NSTextView alloc] initWithFrame:insetRect];
[infoTextView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[infoTextView setBackgroundColor:[NSColor clearColor]];
[infoTextView setTextContainerInset:NSZeroSize];
[infoTextView setEditable:YES];
[infoTextView setSelectable:YES];
[infoTextView setAutomaticLinkDetectionEnabled:YES];
我的目标是 10.6,并认为 automaticLinkDetectionEnabled 意味着当用户键入一个作为网站地址的字符串时,NSTextView 会将其格式化为蓝色,带下划线,并使其成为可点击的链接。这不会发生。它只是作为纯文本阅读。我在 textView 的 textStorage 上没有格式。
文档内容如下:
“自动链接检测导致表示在视图中键入的 URL 的字符串自动成为指向这些 URL 的链接。”
我还需要做什么?