如何使控件“可选项化”当从 Cocoa 应用程序中的插件加载时?
我有一个应用程序加载有自己的 UI 的插件。 我的AppDelegate中有一个名为ContainerView的IBOutlet。 当插件加载时,它将自己的视图(存储在插件包的 xib 中)放入容器视图中,如下所示
[ContainerView addSubview:viewFromPlugin];
当视图加载时,一切都很好,但是当我按 Tab 时,唯一获得焦点的控件是 ContainerView 外部的控件,而其中的控件都没有获得焦点。
我尝试将容器视图设置为initialFirstResponder,并尝试将选项卡顺序中最后一个按钮的nextKeyView 连接到ContainerView。
谢谢。
I have an application thad loads in plugins that have their own UI.
There is an IBOutlet called ContainerView in my AppDelegate.
When the plugin loads, it puts its own view (that is stored in a xib in the plugin bundle) into the Container view like so
[ContainerView addSubview:viewFromPlugin];
When the view loads, everything is fine but when I press tab the only controls that get any focus are ones outside of the ContainerView and none of them inside it get focus.
I've tried setting the container view as the initialFirstResponder and I've tried hooking up the nextKeyView from the last button in the tab order to the ContainerView.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是你想做的吗?让容器视图成为关键视图?听起来不像。听起来您希望插件视图(或其中的视图)成为关键视图。
Apple 文档的这一部分解释了所有键视图循环的不同方面。 我相信您会想要设置容器视图的
nextKeyView
以及它之前的视图,或者覆盖容器视图的nextValidKeyView
方法——可能两者兼而有之。您还可以尝试将前一个视图的nextKeyView
直接设置为插件视图的nextValidKeyView
,完全跳过容器视图。Is that what you want to do? Make the container view the key view? It doesn't sound like it; it sounds like you want the plug-in view (or a view within it) to become the key view.
This section of the Apple documentation explains all of the different aspects of the key view loop. I believe you'll want to either set the
nextKeyView
of the container view as well as the view before it, or override the container view'snextValidKeyView
method—possibly both. You might also try setting the previous view'snextKeyView
directly to the plug-in view'snextValidKeyView
, skipping over the container view entirely.您是否尝试在 ContainerView 上调用BecomeFirstResponder 方法?
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/becomeFirstResponder
UIView类继承自UIResponder 。
Did you try calling the becomeFirstResponder method on your ContainerView?
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/becomeFirstResponder
UIView classes inherit from UIResponder.