gpt4 book ai didi

objective-c - NSPopUpButton:NSPopUpButtonCell 已弃用?

转载 作者:行者123 更新时间:2023-12-03 17:01:10 25 4
gpt4 key购买 nike

documentation for NSPopUpButton状态:

An NSPopUpButton object uses an NSPopUpButtonCell object to implement its user interface.

我从NSPopUpButtonCell派生了一个新类,它实现了drawBorderAndBackgroundWithFrame:inView:来实现自定义绘图。此外,我从 NSPopUpButton 派生了一个新类,并使用 cellClass 来使用我的派生类。 (即我不通过界面生成器工作。)

然而,随着 macOS 10.14 beta 的出现,这个例程不再被调用,我观察到“正常”(即非定制)绘图。

感谢@Marc T.'s answer ,我(认为我)能够将问题本地化为这样一个事实:仅当在派生单元中实现 drawInteriorWithFrame:inView: 时,单元显然才会调用 drawBorderAndBackgroundWithFrame:inView: .

我找不到这方面的可靠文档。有吗?

最佳答案

如果 macOS 10.14 中有这样的变化,我想苹果会在 WWDC 2018 上宣布这一点。快速检查 Interface Builder 后发现,到目前为止没有任何变化。创建 NSPopUpButtonCell 的子类以将其用作弹出按钮单元格的类仍然按预期工作。我必须提到的是,只有在实现了drawInterior 的情况下才会调用drawBorderAndBackground。由于我以前从未使用过drawBorderAndBackground,所以我不能说这是否是从以前的版本到10.14的更改。

class Cell: NSPopUpButtonCell {

override func drawInterior(withFrame cellFrame: NSRect, in controlView: NSView) {
super.drawInterior(withFrame: cellFrame, in: controlView)
print("drawInterior")
}

override func drawBorderAndBackground(withFrame cellFrame: NSRect, in controlView: NSView) {
super.drawBorderAndBackground(withFrame: cellFrame, in: controlView)
print("drawBorderAndBackground")
}
}

希望这有帮助。

关于objective-c - NSPopUpButton:NSPopUpButtonCell 已弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51175125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com