简体   繁体   中英

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

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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