[英]How can I get notified when NSViewController instance is loaded / unloaded
On iOS, there are viewDidAppear / viewDidDisappear methods. 在iOS上,有viewDidAppear / viewDidDisappear方法。 They are also being added to Yosemite (see https://developer.apple.com/library/prerelease/mac/releasenotes/AppKit/RN-AppKit/#10_10ViewController ).
它们也被添加到优胜美地(请参阅https://developer.apple.com/library/prerelease/mac/releasenotes/AppKit/RN-AppKit/#10_10ViewController )。
Question: how can I detect when my view is appearing / disappearing pre-OS X 10.10? 问题:如何检测OS X 10.10之前的视图何时出现/消失?
You can use loadView 您可以使用loadView
- (void)loadView {
[super loadView];
}
I don't know your goal but if you really needed it. 我不知道您的目标,但是您是否真的需要它。 There was
viewDidUnload
and viewWillUnload
but Apple deprecated them and warned people that they are being misused. 曾经有
viewDidUnload
和viewWillUnload
但是Apple弃用了它们,并警告人们它们被滥用。
The cost of releasing objects when the view unload is not expensive so they just got rid of it. 当视图卸载时释放对象的代价并不昂贵,因此它们就摆脱了它。
The only way I can see pre-Yosemite systems using something similar to viewDidDisappear
is to subclass NSView
and overriding viewDidHide
to call a delegate class. 我能看到使用类似于
viewDidDisappear
东西的约塞米蒂系统的唯一方法是子类化NSView
并重写viewDidHide
来调用委托类。
Or you could do some method swizzling on the NSView
class on pre-Yosemite systems. 或者,您可以在优胜美地之前的系统上对
NSView
类进行一些处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.