gpt4 book ai didi

cocoa - NSTextView的automaticLinkDetectionEnabled方法如何工作?

转载 作者:行者123 更新时间:2023-12-03 16:59:44 25 4
gpt4 key购买 nike

我正在以编程方式设置 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 进行格式化。

文档内容如下:

'Automatic link detection causes strings representing URLs typed in the view to be automatically made into links to those URLs.'

我还需要做什么?

最佳答案

文本设置为:

[infoTextView checkTextInDocument:nil];

这将遍历 View 中的所有文本,并将所有 URL 转换为链接。

关于cocoa - NSTextView的automaticLinkDetectionEnabled方法如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4686331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com