简体   繁体   English

如何在两个容器视图中处理两个集合视图

[英]How to handle two collection views inside two container views

I have a view controller with segmented view controller at top and then two container views placed upon another. 我有一个视图控制器,在顶部有分段视图控制器,然后将两个容器视图放在另一个视图上。 I will be hiding and showing them based upon selection from segmented controller. 我将根据分段控制器的选择隐藏并显示它们。

Have a look at screenshot: 2ContainerViews_2childViews 看一下屏幕截图: 2ContainerViews_2childViews

Each child view has collection view on it. 每个子视图都有集合视图。 Now i am not sure how to start ie 现在我不确定如何开始

  • how to take these two collection views along? 如何处理这两个集合视图?

  • Can i link both of these child views and hence collection views to single class? 我可以将这些子视图以及集合视图都链接到单个类吗? or do i have to implement three classes, one for main view controller, and two for collection views on child views separately? 还是我必须实现三个类,一个用于主视图控制器,另外两个用于子视图上的集合视图?

Please help. 请帮忙。 I will be thankful. 我会很感激的。

Based on the information you've given here, it sounds like these two collection views are mutually exclusive (you are only displaying them one at a time). 根据您在此处提供的信息,听起来这两个集合视图是互斥的(您一次只能显示一个)。 If this is the case, you can actually simplify your implementation a great deal by simply using 1 view controller with a single collection view inside it. 如果是这种情况,您实际上可以通过简单地使用内部包含单个集合视图的1个视图控制器来简化您的实现。 Then, based on which set of data you want display, you just change what that collection view displays, either by swapping out the datasource object, or by just returning the other set of data in the delegate methods by checking which mode is activated. 然后,根据要显示的数据集,只需换出数据源对象,或仅通过检查激活的模式返回委托方法中的另一组数据,即可更改该集合视图显示的内容。 Then just call reloadData when the user taps the button to switch between datasets. 然后,当用户点击按钮在数据集之间切换时,只需调用reloadData即可。

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

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