gpt4 book ai didi

macos - NSPersistentDocument – 如何访问窗口?

转载 作者:行者123 更新时间:2023-12-03 16:55:18 27 4
gpt4 key购买 nike

我想设置 NSPersistentDocument 对象窗口的一些属性。我如何访问它?

还有比这样更好的方法吗?

    [[[[self windowControllers] objectAtIndex:0] window] setBackgroundColor:[NSColor blueColor]];

最佳答案

不,这就是获得它的方法。 NSWindowController 负责管理窗口,这就是它拥有窗口的原因。

如果您要自定义窗口外观或行为,实际上最好将 NSWindowController 子类化并将自定义窗口的代码放入该类中,而不是您的 NSDocument code>/NSPersistentDocument 子类。

NSDocument(和 friend )用于管理数据,NSWindowController 用于管理 UI。除了最简单的应用程序之外,在所有应用程序中,您都应该子类化 NSWindowController

关于macos - NSPersistentDocument – 如何访问窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7691227/

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