有没有办法更改 Swift 中 NSTextView 容器的字符串值?
Is there a way to change the string value of an NSTextView container in Swift?
我似乎无法找到一种方法来使用 Swift 更改 NSTextView 的 text/string 值。有谁知道这是怎么做到的吗?如果没有办法做到这一点,另一种方法就是想出一种方法来制作一个人们可以滚动浏览和阅读的文本区域。我该怎么做?我正在使用 Xcode 7.1.1,我正在使用 Swift 2.1。谢谢!
你试过什么?这在 Playground 的快速测试中有效:
//: Playground - noun: a place where people can play
import Cocoa;
var t = NSTextView(frame: NSRect(x: 0, y: 0, width: 100, height: 100));
t.string = "Hello";
原来我只是使用了标签 - 效果更好!
我似乎无法找到一种方法来使用 Swift 更改 NSTextView 的 text/string 值。有谁知道这是怎么做到的吗?如果没有办法做到这一点,另一种方法就是想出一种方法来制作一个人们可以滚动浏览和阅读的文本区域。我该怎么做?我正在使用 Xcode 7.1.1,我正在使用 Swift 2.1。谢谢!
你试过什么?这在 Playground 的快速测试中有效:
//: Playground - noun: a place where people can play
import Cocoa;
var t = NSTextView(frame: NSRect(x: 0, y: 0, width: 100, height: 100));
t.string = "Hello";
原来我只是使用了标签 - 效果更好!