以编程方式创建一个带有两个使用导航控制器的 uiviewcontroller 的 splitviewcontroller
我想以编程方式创建一个 UISplitViewController ,并将两个 UIViewController 子类作为其主控制器和详细控制器(左窗格和右窗格),我用它们来处理各种事情,例如选择单元格时的处理等。
我的问题是,我不确定如何在这些自定义主控制器和详细控制器中创建导航控制器并将它们连接到 splitview 控制器。目前,我像这样添加我的控制器:
mSplitViewController.viewControllers = [NSArray
arrayWithObjects:mSplitMasterController,mSplitDetailController, nil];
并且在每个自定义控制器中我创建了一个容器 UIView,我可以在其中组装我的子视图。我不确定如何将导航控制器添加到其中。我是否需要在自定义控制器的 loadView 中基本上执行类似的操作?
[self.view addSubview:mNavigationController.view];
在构建导航控制器将管理的控制器(及其视图)之后?
I would like to create a UISplitViewController programmatically and have as its master and detail controller (the left and right pane), two UIViewController subclasses which I use to handle various things like processing when cells are selected and so forth.
My problem is that I'm not certain how to create navigation controllers within these custom master and detail controllers and hook them up to the splitview controller. Currently, I add my controllers like this:
mSplitViewController.viewControllers = [NSArray
arrayWithObjects:mSplitMasterController,mSplitDetailController, nil];
and I within each custom controller I have a container UIView created on which I can assemble my subviews. I'm not sure how I add the navigation controllers to these. Do I need to basically do something like this within my custom controllers' loadView?
[self.view addSubview:mNavigationController.view];
after constructing the controllers (and their views) that the navigation controller will manage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要 UIView 容器。如果想使用容器,您将需要 UIViewController。不管怎样,只需将导航控制器直接添加到数组中即可。稍后您可以从同一数组访问它们,以在另一个拆分视图上推送和弹出。
You don't need UIView containers. If wanted to use containers you would need UIViewControllers. Regardless just add the navigation controller to the array directly. Later you can access them from the same array to push and pop on the other split view.