UISplitViewController - 通过故事板segues的多个细节视图控制器 [英] UISplitViewController - Multiple Detail View Controllers via storyboard segues

查看:115
本文介绍了UISplitViewController - 通过故事板segues的多个细节视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为iPad做一个项目,我想在其中使用分割视图控制器。我将为主视图控制器中的每个单元格提供不同的详细视图控制器。

I'm trying to do a project for the iPad in which I'd like to utilized the split view controller. I'll be having different detail view controllers for each of the cells in the master view controller.

我看到一个解决方案如何通过此站点中的故事板segue执行此操作。

I saw one solution how to do this via storyboard segues in this site.

他基本上将每个UITableViewCell链接到不同的详细视图控制器。但我想知道这是一种稳定还是好的方式。我的意思是,它是否比编程更好或更稳定?如果有的话,做他的方法有什么后果?

He basically linked each of his UITableViewCell to different detail view controllers. But I'd like to know if this is a "stable" or a "good" way of doing this. I mean, is it any better or as stable as doing it programmatically? What would be the consequences of doing his method, if there are any?

这是链接到我找到的解决方案

Here is the link to the solution I found

推荐答案

这是一种一个棘手的问题,即使它是一个非常常见的用例。

This is kind of a tricky one, even though it's an incredibly common use case.

1)一个想法是让一个空的根视图控制器作为你的细节,它处理引擎盖下的segues以快速转换到你真正关心的细节视图,利用替换segue。这应该技术上修复左上方的后退按钮,仍然允许您弹出到root并且不显示空控制器。虽然没有测试过这些,所以我不确定。

1) One idea is to have an empty root view controller as your detail and it handles managing segues under the hood to quickly segue to the detail view you actually care about, utilizing the "replace" segue. This should "technically" fix having the "back" button at the top left and still allow you to pop to root and not have it show the empty controller. Haven't tested these though, so I'm not sure.

编辑:在Xcode 6中,替换segue可以通过show方便地处理detailsegue,专门用于拆分视图控制器上的此类视图处理。我建议在新项目中专门使用此方法。 查看示例代码。

In Xcode 6, the "replace" segue is conveniently handled by a "show detail" segue which is used specifically for this type of view handling on Split View Controllers. I recommend using this method exclusively in new projects. See sample code.

2)另一个想法是在你的故事板中有一个单独的导航控制器(一个连接,其余全部搁浅)。每个细节视图类型一个,并点击主菜单将简单地将详细视图的导航控制器交换到您关心的那个。

2) The other idea is to have separate navigation controllers in your storyboard (one connected, the rest all stranded). One for each detail view type and tapping on the master menu will simply swap the navigation controller for the detail view to the one you care about.

AppDelegate中与此类似的代码:

Code similar to this in AppDelegate:

self.detailNavigationController = [self.masterNavigationController.storyboard instantiateViewControllerWithIdentifier:@"MyChosenNavigationControllerStoryboardId"];
self.splitViewController.viewControllers = @[self.splitViewController.viewControllers[0], self.detailNavigationController];
self.splitViewController.delegate = (id)self.detailNavigationController.topViewController;

第二种方式的缺点是在内存测试中,它似乎没有交换新的导航控制器可以释放旧导航控制器正在使用的所有内存。因此,对于简单的应用程序使用它是好的,但不适用于任何疯狂复杂的应用程序。

The downside to this second way is that in memory tests, it doesn't appear that swapping a new nav controllers in frees up all of the memory that the old nav controller was using. So it's good to use for simple apps but not for anything crazy complex.

这篇关于UISplitViewController - 通过故事板segues的多个细节视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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