单击后更改 NSTableCellView 中 NSButton 的文本

Mat*_*att 3 view nstableview swift

我有一个NSTableCellView包含嵌入的NSProgressIndicators 和NSButtons的自定义s表,我想在单击后立即更新,并在计时器上定期更新。这是迄今为止我的代码示例:

func sound(sound: NSSound, didFinishPlaying aBool: Bool) {
    pbNowPlaying.doubleValue = sound.currentTime
    if aBool == true {
        self.btnPlay.stringValue = "Play"
        self.btnPlay.state = NSOffState
        self.pbNowPlaying.doubleValue = 0
    }
    self.needsDisplay = true
}
Run Code Online (Sandbox Code Playgroud)

这个(和其他self.needsDisplay = true设置的代码)似乎没有更新视图。当我手动重新加载表数据时,进度条移动(已绑定到NSSounds.currentTime值),但按钮文本/状态不会改变。

有什么建议吗?

使用 Swift、Xcode 6.4、OS X 10.10.4 进行编码

Mat*_*att 8

好吧,我觉得很愚蠢,但对于可能NSButton遇到相同问题的其他人:要修改 上的文本,您需要更改.title属性,而不是.stringValue属性。