如何使用 swift 检查 NSTextField
的拼写?我已经在使用 controlTextDidChange
来验证文本。 This solution似乎提到将第一响应者转换为 NSTextView
但我不确定使用强制转换是否有可能 swift 。我知道如果我更改为 NSTextView
会更容易,但如果可能的话我想避免这种情况。
最佳答案
这应该可以帮到您。
// Focus TextField
phraseTextField.becomeFirstResponder()
// Enable Continous Spelling
let textView: NSTextView = (self.window!.firstResponder as! NSTextView)
textView.continuousSpellCheckingEnabled = true
改编自:How do I enable spell checking within an NSTextField on Mac OS X?
在其他情况下,将 NSTextField
更改为 NSTextView
可能会更好。只需使用“ TextView ”(在对象库中搜索 NSTextView),拼写检查将默认打开。据我所知,NSTextFields 在某些情况下根本不支持拼写检查。
关于swift - 使用 Swift 在 NSTextField 中拼写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35685390/