简体   繁体   English

在Xcode 4.2中使用故事板的UISplitView中使用多个细节视图?

[英]Using multiple detail views in a UISplitView with Storyboards in Xcode 4.2?

I'm trying to create an iOS 5 application with a SplitView Controller that uses multiple detailviews. 我正在尝试使用具有多个详细视图的SplitView控制器创建iOS 5应用程序。 Here's the rub. 这就是问题。 I'm trying to do it using Storyboards. 我正在尝试使用Storyboard。 I've found a number of tutorials explaining how to do it in previous versions of Xcode, but none addressing Storyboards. 我发现了一些教程,解释了如何在以前版本的Xcode中执行此操作,但没有一个解决故事板。

The one exception creates a tab bar controller in the master view, which is not something I want to use. 一个例外在主视图中创建了一个标签栏控制器,这不是我想要使用的。 I tried removing the tab bar and modifying the code but was unsuccessful. 我尝试删除标签栏并修改代码,但未成功。

I did figure out that I could attach a replace Segue to a static cell in the master view. 我确实发现我可以在主视图中将替换Segue附加到静态单元格。 It allows me to specify the type as a detail split, which accomplishes most of what I'm trying to do. 它允许我将类型指定为细节分割,这完成了我正在尝试的大部分内容。 It loads the new detail controller. 它加载新的细节控制器。

However, the button that shows the master popover disappears during he transition. 但是,显示主弹出窗口的按钮在转换过程中会消失。 I believe I can probably prevent that from happening using this method: 我相信我可以使用这种方法防止这种情况发生:

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

Unfortunately, I'm not sure exactly what code to place there to prevent the button from disappearing. 不幸的是,我不确定在那里放置什么代码来防止按钮消失。 Do I need each detail controller as a delegate to the master somehow? 我是否需要将每个细节控制器作为主人的代表?

Has anyone gotten multiple detail views to work using storyboards and if so can you point me in the direction of a good tutorial? 有没有人使用故事板获得多个细节视图,如果是这样,你能指点我一个好的教程的方向吗? Thank you so much for the help! 非常感谢你的帮助!

I faced a similar situation and checked the link to the raywenderlich.com. 我遇到了类似的情况并检查了链接到raywenderlich.com。 However I found managing the splitview delegate kind of too complicated, and it makes reuse between iPhone and iPad difficult. 但是我发现管理splitview委托太复杂了,它使iPhone和iPad之间的重用变得困难。 My solution is to create a DetailedContainerViewController as the right side view controller. 我的解决方案是创建一个DetailedContainerViewController作为右侧视图控制器。 And add the view controllers to be displayed on the right side as the child view controllers of the container controller. 并添加要在右侧显示的视图控制器作为容器控制器的子视图控制器。 In this way only the DetailedContainerViewController needs to implement the SplitView delegate. 这样只有DetailedContainerViewController才需要实现SplitView委托。 So there is no need to worry about the delegate. 所以没有必要担心代表。

Take a look at the sample code I wrote on github: 看看我在github上写的示例代码:

https://github.com/raoying/SplitView-Sample https://github.com/raoying/SplitView-Sample

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM