简体   繁体   English

ios-使用情节提要的tabbarcontroller内的splitviewcontroller

[英]ios - splitviewcontroller inside tabbarcontroller using storyboards

I have my app mapped out using storyboards where there is an entry screen that segues to a tabbarcontroller which contains 3 tabs. 我使用情节提要映射了我的应用程序,其中有一个进入屏幕,可以选择到包含3个选项卡的tabbarcontroller。 Each tab contains a splitviewcontroller and I have written classes for each master and detail view controller. 每个选项卡都包含一个splitviewcontroller,并且我为每个主视图和详细视图控制器编写了类。 The bit I'm not sure on is how to give each masterviewcontroller (that controls the table on the left hand side) a reference to the detailviewcontroller. 我不确定的是如何给每个masterviewcontroller(控制左侧的表)提供对detailviewcontroller的引用。

I can see in the attributes inspector there is an identifier field, should i put something in here for the detailviewcontroller (eg 'detailviewcontroller1) and then somehow get that object by it's instance name in code? 我可以在属性检查器中看到一个标识符字段,是否应该在此处为detailviewcontroller添加一些内容(例如'detailviewcontroller1),然后以某种方式通过代码中的实例名称获取该对象?

So your SplitViewController should be connected to 2 segues that connect two separate UINavigationControllers (one for Master and one for Detail). 因此,您的SplitViewController应该连接到两个连接两个单独的UINavigationControllers(一个用于Master,一个用于Detail)的segue。 These two nav controllers will connect to your two VC's (Master and Detail). 这两个导航控制器将连接到您的两个VC(主控和明细)。

You will then create a property for that detail VC inside the master VC and pass whatever data you need to when the user selects a row from the TV. 然后,您将在主VC内为该详细VC创建一个属性,并在用户从电视中选择一行时将所需的任何数据传递给它。

If you need to see how this is supposed to be layed out and wired up, just create a new iPad application using the Master-Detail template. 如果您需要了解如何进行布局和布线,只需使用Master-Detail模板创建一个新的iPad应用程序。

Both your master and detail view controllers will have a property, splitViewController , that holds a pointer to the split view controller. 您的主视图控制器和详细视图控制器都将具有splitViewController属性,该属性包含指向拆分视图控制器的指针。

The split view controller has a property, viewControllers , which holds an array of the view controllers contained in the split view. 拆分视图控制器具有viewControllers属性,该属性保存拆分视图中包含的视图控制器数组。 This array will always contain 2, and only 2, view controllers - at index 0 is the master controller, and at index 1 is the detail controller. 该数组将始终包含2个视图控制器,并且仅包含2个视图控制器-索引为0的是主控制器,索引为1的是细节控制器。

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

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