简体   繁体   English

NSView的viewWillAppear等效项是什么

[英]What is the equivalent of viewWillAppear for NSDocument

I have a NSDocument based application with a nib that represents the visual document. 我有一个基于NSDocument的应用程序,其中的笔尖代表可视文档。 As soon as the view Appeared I want to trigger some actions. 该视图出现后,我想触发一些操作。

For a "normal" UIViewController I would simply override viewDidAppear: . 对于“普通” UIViewController我将仅重写viewDidAppear: However, NSDocument does not have this method, even though it has a view per document. 但是,即使NSDocument每个文档都有一个视图,它也没有此方法。

NSDocument offers NSDocument提供
-(void)windowControllerDidLoadNib:(NSWindowController *)aController; method. 方法。
I think this is what you are looking for. 我认为这就是您想要的。
The document window controllers are still accessible using NSDocument 's windowControllers method. 仍可以使用NSDocumentwindowControllers方法访问文档窗口控制器。

If you have more precise requirements on window appearing/disappearing, becoming key, etc..., you could handle that with window notifications , or window delegation system . 如果您对窗口的出现/消失,变成键等有更精确的要求,则可以使用窗口通知窗口委托系统来处理

-[NSDocument showWindows] ,可以在末尾添加一些自定义逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM