我找不到任何似乎与NSTextView
. 我知道 aNSTextView
使用复杂的结构(带有NSLayoutManager
等...),但我找不到修改当前text
值的有效方法。
问问题
24551 次
6 回答
28
正确的方法是“setString”[textView setString:@"the string"];
于 2013-05-12T08:57:04.143 回答
22
在插座 textView Swift Xcode 8.0 上设置文本
textView.string = newString
于 2016-09-30T15:37:46.560 回答
6
如果您想设置属性文本(格式化文本),请尝试
[myTextView setAttributedString:(NSAttributedString*)attrString].
NSTextView 包含一个实际保存文本的 NSTextStorage 对象...
于 2013-08-07T06:31:38.873 回答
6
目标 C / Xcode 9
[myTextView setString:@"The string"];
self.myTextView.string = @"My String";
斯威夫特/ Xcode 9
self.myTextView.setString("MyString")
self.myTextView.string = "My String"
于 2018-05-03T10:10:36.167 回答
5
像这样的东西:
[textView setString:@"new value"];
于 2013-02-01T12:21:05.003 回答
0
几乎就在那里 - 程序在下面 - 这几乎可以工作。有两个突出的问题:
1)在文本中设置正确的选择点需要两次鼠标单击,第一个总是到文本的末尾。第二个到所需
位置
2)在shell中打印一个奇怪的错误--[LUPresenter animationControllerForTerm:atLocation:options:]中的断言失败,/SourceCache/Lookup/Lookup-160/Framework/Classes/LUPresenter.m:
import Cocoa
class MyAppDelegate: NSObject, NSApplicationDelegate {
let window = NSWindow()
func applicationDidFinishLaunching(aNotification: NSNotification) {
window.setContentSize(NSSize(width:600, height:200))
window.styleMask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask
window.opaque = false
window.center();
window.title = "My window"
let ed = NSTextView(frame: NSMakeRect(20, 10, 180, 160))
ed.font = NSFont(name:"Helvetica Bold", size:20)
ed.string = "edit me"
ed.editable = true
ed.selectable = true
window.contentView!.addSubview(ed)
window.makeKeyAndOrderFront(window)
window.level = 1
}
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
}
}
let app = NSApplication.sharedApplication()
app.setActivationPolicy(.Regular)
let obj = MyAppDelegate()
app.delegate = obj
app.run()
于 2015-12-26T13:39:19.200 回答