如何NSTextField
使用 swift 检查 a 的拼写?我已经controlTextDidChange
用来验证文本。该解决方案似乎提到将第一响应者转换为 aNSTextView
但我不确定是否可以通过 swift 强制使用。我知道如果我改为 a 会更容易,NSTextView
但如果可能的话,我想避免这种情况。
问问题
685 次
1 回答
2
这应该可以帮助你。
// Focus TextField
phraseTextField.becomeFirstResponder()
// Enable Continous Spelling
let textView: NSTextView = (self.window!.firstResponder as! NSTextView)
textView.continuousSpellCheckingEnabled = true
改编自:如何在 Mac OS X 上的 NSTextField 中启用拼写检查?
在其他情况下,将 s 更改NSTextField
为NSTextView
s 可能会更好。只需使用“文本视图”(在对象库中搜索 NSTextView),拼写检查将默认打开。据我所知,NSTextFields 在某些情况下根本不支持拼写检查。
于 2016-02-28T19:13:43.640 回答