[英]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的dataSource
和delegate
,也可以为每个表都具有一个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页面上有详细的用法
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.