可可错误:'NSButton'类型的值没有成员'setTitle'

时间:2017-02-14 15:33:47

标签: cocoa swift3

在Swift3中,我有一个声明如下的按钮:

 @IBOutlet  weak var transmitButton: NSButton!

我正在尝试设置它的标题:

func textViewDidChange(_ textView: NSTextView) {
        // If we're already transmitting, stop
        if transmitButton.state == NSOnState {
            transmitButton.setNextState()
            transmitButton.setTitle("On", for: .normal)
        }
    }

我收到了这个错误:

Value of type 'NSButton' has no member 'setTitle'

我很感激任何想法/

1 个答案:

答案 0 :(得分:2)

这是 NS 按钮没有{strong> UI 中的setTitle:for:方法 按钮,只有title属性:

transmitButton.title = "On"
相关问题