如何在Master

编程入门 行业动态 更新时间:2024-10-25 06:20:58
如何在Master-Detail应用程序中添加多个Detail View控制器(How to add multiple Detail View Controllers in Master-Detail application)

我正在尝试构建一个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.

更多推荐

本文发布于:2023-07-06 07:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Master

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!