我試圖從背景操作中繪製到NSView
,但沒有看到任何效果。從後臺操作中繪製NSView不起作用
let queue = OperationQueue()
queue.addOperation() {
doTheBackgroundStuff()
}
開始後臺操作,它正在做大量的計算。在AppDelegate中我有
@IBOutlet weak var image: NSImageView! // some image to show
@IBOutlet weak var number: NSTextField! // a corresponding number
@IBOutlet weak var mainView: NSView! // the main view holding the above
分配
number.intValue = Int32(someNumber)
從後臺操作發行的定期(通常)。但文字永遠不會改變。我在IB中爲視圖和TextField設置了「可同時繪製」。我也試過
if mainView.lockFocusIfCanDraw() {
mainView.setNeedsDisplay(mainView.rectPreservedDuringLiveResize)
mainView.unlockFocus()
}
之後的文本字段分配。也無濟於事。
執行到達'if mainView.lockFocusIfCanDraw(){...}'的內部嗎? –
@ l'L'l是的,它的確如此。 –
您可能想要顯示您用來更新文本字段的代碼。 –