how to place two collection views on top of a UIView with a UIImage view in between

StackOverflow https://stackoverflow.com/questions/17201999

  •  01-06-2022
  •  | 
  •  

Question

iOS Simulator Screen shot Jun 19, 2013 2.43.43 PM.png!Main Storyboard description

Était-ce utile?

La solution

This is really simple. In your collection view datasource methods, make sure you distinguish between the two views by keeping strong references to the views e.g. as properties:

if (collectionView == _topCollectionView) {
   // provide the data for the top view
}
else {
   // provide the data for the bottom view
}

Do the same in didSelectItemAtIndexPath. Determine which collection view has been interacted with, change the appropriate data in for the other one and reload and/or update your image view.

You need to use a standard view controller and add the delegate and datasource declarations manually.

@interface ViewController : UIViewController 
         <UICollectionViewDataSource, UICollectionViewDelegate>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top