简体   繁体   English

在UITableViewController iOS中实现另一个表视图

[英]Implementing another table view in a UITableViewController ios

I need to add a new table view to my UITableViewController which will includes a different data and design. 我需要在UITableViewController中添加一个新的表视图,其中将包含其他数据和设计。

在此处输入图片说明

the above prototype cells is the new table view I've added in storyboard, and the main table view is the second one which includes (title, label, and image). 上面的原型单元是我在情节提要中添加的新表格视图,主表格视图是第二个表格视图,其中包括(标题,标签和图像)。

Is it allowed to create another table view in UITableViewController, or should I create a UIViewController and implement the two tables in it??? 是否可以在UITableViewController中创建另一个表视图,还是应该创建一个UIViewController并在其中实现两个表???

In fact, I've finished the implementation of the first table view controller, so I need to implement the new one. 实际上,我已经完成了第一个表视图控制器的实现,因此需要实现新的表视图控制器。

the attached image is showing what I want: 所附图片显示了我想要的: 在此处输入图片说明

You will be better off with a UIViewController that has two tableViews as subviews if you want both of your tables to be shown at the same time. 如果希望同时显示两个表,则最好使用具有两个tableViews作为子视图的UIViewController UITableViewController should be used only when there is just one tableView shown at a certain time. 仅在特定时间显示一个tableView时,才应使用UITableViewController

You can either have one UIViewController being the dataSource and delegate for both of the tableViews, or have a UITableViewController for each of your tables and add them as subviews to a UIViewController that will be a container view for both of them. 您可以将一个UIViewController用作两个tableView的dataSourcedelegate ,也可以为每个表都具有一个UITableViewController并将它们作为子视图添加到UIViewController ,这将是两个表的容器视图。 The latter will probably save you some time debugging possible issues as having two tableViews with a single delegate / dataSource requires a lot of duplicate code in the same place. 后者可能会节省您一些时间来调试可能的问题,因为具有两个具有单个delegate / dataSource tableViews在同一位置需要大量重复代码。

I think you should use UIExpandableTableView 我认为您应该使用UIExpandableTableView

there is detailed usage on github page github页面上有详细的用法

UIExpandableTableView的示例

Scree example of UIExpandableTableView UIExpandableTableView的Scree示例

Are you looking to have them be two independent tables, or is it a master/child setup? 您是否希望它们成为两个独立的表,还是主/子设置? If they are independent, I suggestion using one table and two sections, then depending on the section number return to correct cell. 如果它们是独立的,我建议使用一张表和两节,然后根据节号返回到正确的单元格。 For master/child, think about making a view that looks like a cell and have the master cells be the sections views and the children be the actually rows. 对于主/子级,请考虑制作一个看起来像一个单元格的视图,并让主单元格成为截面视图,而子级实际上是行。 You can make a section class that stores if the children are visible or not and in the numberOfRowsInSection method return the count if visible or 0 if not. 您可以创建一个节类来存储子项是否可见,并且在numberOfRowsInSection方法中,如果可见则返回计数,否则返回0。

Just a couple ideas 只是几个想法

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

相关问题 iOS UITableViewController didSelectRowAtIndexPath不加载另一个UITableViewController - iOS UITableViewController didSelectRowAtIndexPath not loading another UITableViewController iOS覆盖视图 - 使用视图屏蔽UITableViewController部分屏蔽UITableViewController - iOS Overlay View - Masking UITableViewController with a view is partially masking UITableViewController UITableViewController 之外的静态表格视图 - Static table view outside UITableViewController iOS:无法在UITableViewController上创建自定义视图 - iOS: can not create custom view on UITableViewController 将tableView交换到UITableViewController中的另一个视图中 - Swapping tableView into another view within UITableViewController 用另一个笔尖的内容覆盖UITableViewController视图 - Cover UITableViewController view with contents of another nib 帮助实现“ Horizo​​ntal UITableViewController”吗? - Help implementing “Horizontal UITableViewController”? 你可以将UITableViewController的TableView添加到另一个View吗? - Can you add a UITableViewController's TableView to another View? 使用分组的UITableViewController将NSMutableArray数据传递到另一个视图 - Passing NSMutableArray data to another view using a grouped UITableViewController 非法配置 - 静态表视图仅在嵌入UITableViewController时有效 - illegal configuration - Static table view are only valid when embedded in UITableViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM