[英]Callback when NSView is added to NSWindow
I am given a NSView from a third party library. 我从第三方库获得了NSView。 When I am given the NSView it is not yet added to a NSWindow. 当我得到NSView时,它还没有添加到NSWindow中。 I need to wait until the third party library adds the NSView to a NSWindow before executing some of my code. 我需要等到第三方库将NSView添加到NSWindow之后才能执行一些代码。 There is no method for the third party library to notify me when this happens. 发生这种情况时,第三方库没有任何方法可以通知我。 I need to check for this condition myself and I need the solution to work on OSX 10.9/10.10/10.11. 我需要自己检查这种情况,并且需要解决方案才能在OSX 10.9 / 10.10 / 10.11上运行。
KVO on the "window" property in NSView. NSView中“窗口”属性上的KVO。 Works great but unfortunately the "window" property in NSView is not KVO compliant in OSX 10.9. 效果很好,但不幸的是,NSView中的“ window”属性在OSX 10.9中不兼容KVO。
Spawn a thread and periodically check whether the "window" property on the NSView != nil. 生成线程并定期检查NSView!= nil上的“ window”属性。 Unfortunately leads to some slight delay. 不幸的是导致一些轻微的延迟。
Are there any KVO alternatives I can use for pre 10.10? 我可以在10.10之前的版本中使用KVO替代品吗? Or any other solutions at all? 或根本没有其他解决方案?
不好的方法是创建一个NSTimer来注意将视图添加到窗口中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.