派生自 NSTabViewItem
我正在写一个 Cocoa 应用程序。一个对话框有3个选项卡,有些选项卡需要更多加载时间,所以我想延迟加载它们。由于每个选项卡都是一个 NSTabViewItem 类,因此我尝试从它派生并覆盖它的 view 属性。在视图 getter 方法中,我使用 ViewController 加载视图并返回。在调试中,我发现 NSTabViewItem -view 方法被正确调用,但之后 NSTabView 尝试设置初始 FirstResponder 并崩溃并显示消息:
*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“在 -[NSTabViewItem setInitialFirstResponder”中: ],第一响应者必须从选项卡视图项的视图下降。 (项目:无效的响应者:)'
我尝试重写 -initialFirstResponder 方法以返回已加载视图的子视图,但它仍然在同一位置崩溃。
有谁知道如何让它正常工作?通过派生 NSTabViewItem 来执行此操作是否正确?
谢谢! -乔尼
I'm writing a Cocoa app. One dialog has 3 tabs, some of the tabs needs more loading time, so I want to load them lazily. Since each Tab is a NSTabViewItem class, so I'm trying to derive from it and overriding its view property. In the view getter method, I use a ViewController to load a view and returns out. In Debugging, I found NSTabViewItem -view method is get called correctly, but after that NSTabView tries to set Initial FirstResponder and crashed with message:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'In -[NSTabViewItem setInitialFirstResponder:], the first responder must descend from the tab view item's view. (Item: Invalid responder: )'
I tried to override the -initialFirstResponder method to return a sub-view of my loaded view, but it still crashes the same place.
does anyone know how to get it work correctly? Also is it correct way to do this by deriving the NSTabViewItem?
thanks!
-Jonny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我现在明白了异常。
NSTabViewItem
有它的视图,所以我应该使用它的视图并将我的新视图添加为子视图,例如:OK, I understand the exception now. The
NSTabViewItem
has its view, so I should use its view and add my new view as a subview, like: