在OS X情节提要中通过标识符实例化拆分视图控制器不会加载视图层次结构 [英] Instantiating split view controller by identifier in OS X storyboard does not load view hierarchy

查看:88
本文介绍了在OS X情节提要中通过标识符实例化拆分视图控制器不会加载视图层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Swift OS X应用程序中实现主详细信息视图.顶级视图控制器是带有三个子视图控制器的NSSplitViewController.主视图和第一细节视图是具有固定行为的相当标准的视图.第二个详细视图需要根据第一个详细视图中的选择进行更改.

I'm trying to implement a master-detail-detail view in a Swift OS X application. The top-level view controller is an NSSplitViewController with three subview controllers. The master and first detail views are fairly standard with fixed behaviors. The second detail view needs to change according to the selection in the first detail view.

第二个细节控制器是一个简单的视图控制器,它将通过根据选择安装新的子视图和控制器来响应第一个细节视图中的选择更改.

The second detail controller is a simple view controller, which will respond to selection changes in the first detail view by installing a new subview and controller depending on the selection.

最终内容的备用视图控制器在同一情节提要中实现,没有通过segue连接到任何内容;目的是使用-[NSStoryboard InstantiateControllerWithIdentifier:]创建它们,并将它们安装为子视图控制器和子视图.

The alternate view controllers for the final content are implemented in the same storyboard, not connected to anything by segues; the intent is to create them with -[NSStoryboard instantiateControllerWithIdentifier:] and install them as child view controllers and subviews.

实例化的视图控制器恰好是NSSplitViewControllers.

The instantiated view controllers happen to be NSSplitViewControllers.

这里是问题:当我实例化细节拆分视图控制器并安装它们时,它们是空的.到目前为止,我能观察到的是:

Here's the problem: when I instantiate the detail split view controllers and install them, they are empty. What I have been able to observe so far is:

  • 实例化的视图控制器属于正确的类(NSSplitViewController的子视图);
  • 他们没有子视图
  • 它们确实有splitViewItems,而splitViewItems是我期望看到的视图控制器

我需要做些什么来完全加载/填充已加载的拆分视图控制器吗?

Is there something I need to do to fully load/populate the loaded split view controllers?

TIA, 道格

推荐答案

找到了它.我试图将实例化的NSSplitViewController的"splitView"添加为子视图,而不是其视图"(包含splitView).访问"view"属性将加载视图层次结构;没有使用"splitView".

Found it. I was trying add the instantiated NSSplitViewController's "splitView" as a subview, rather than its "view" (which contains the splitView). Accessing the "view" property loads the view hierarchy; using the "splitView" did not.

这篇关于在OS X情节提要中通过标识符实例化拆分视图控制器不会加载视图层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆