我正在尝试构建一个iPad Master-Detail应用程序。 主视图只是一个TableViewController 。 我想更改用户在主视图中点击的每个不同单元格的完整详细信息视图。 其中一个Detail视图控制器必须允许用户键入数据,另一个允许用户查看内容等。那么如何将更多DetailViewControllers添加到Master-Detail应用程序中?
I am trying to build an iPad Master-Detail app. The master View is just a TableViewController. I want to change the complete Detail view for every different cell the user taps in the Master View. One of the Detail view controllers has to allow the user to type data, the other to view something, etc. So How can I add more DetailViewControllers to a Master-Detail app?
最满意答案
您应该为此目的使用替换segues。 使用替换segue直接从主控制器(而不是单元)连接任意数量的视图控制器,并为它们提供所有标识符。 在didSelectRowAtIndexPath:中,实现将索引路径与要切换到的控制器相关联所需的任何逻辑,然后调用performSegueWithIdentifier:sender:以启动segue。 如果需要将任何数据传递给下一个控制器,可以在prepareForSegue中执行此操作。
You should use replace segues for this purpose. Connect as many view controllers as you want directly from the master controller (not the cells) with replace segues, and give them all identifiers. In didSelectRowAtIndexPath:, implement whatever logic you need to relate the index path to which controller you want to segue to, and then call performSegueWithIdentifier:sender: to initiate the segue. If you need to pass any data on to the next controller, you can do that in prepareForSegue.
更多推荐
发布评论