Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, drag and drop a UICollectionView to your ViewController in XIB, hook up Delegate, datasource to ViewController(this is only main ViewController)</p> <p>Don't use 2 different nib cell for 1 CollectionView, because you can only register 1 Nib. Better use DecorationView as HeaderView. Create new class HeaderView : UICollectionReusableView. This UICollectionReusableView is subclass of UIView can reuse inside UICollectionView together with UICollectionViewCell. Now you can register both type:</p> <pre><code>[self.collectionView registerNib:[UINib nibWithNibName:@"MyCell" bundle:nil] forCellWithReuseIdentifier:@"CELL"]; [self.collectionView registerNib:[UINib nibWithNibName:@"HeaderView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderCell"]; </code></pre> <p>Next, you drag another UICollectionView to this HeaderView, hook up with IBOutlet inside HeaderView.h. Here, it's better to set Delegate, DataSource to this class for control. Also register what Nib Cell this CollectionView will use. Do it in awakeFromNib because you registerNib before</p> <pre><code>- (void)awakeFromNib{ [self.topCollectionView registerNib:[UINib nibWithNibName:@"TopCell" bundle:nil] forCellWithReuseIdentifier:@"TopCell"]; [self.topCollectionView setDataSource:self]; [self.topCollectionView setDelegate:self]; } </code></pre> <p>It's will work well, if you store your datasource outside, just make another property and assign to it, then use for return inside datasource here.</p> <p>If you want to know when click on Cell inside headerView, Use a customDelegate protocol to send delegate to ViewController when click on HeaderCell. </p> <p>This is my code, hope you understand and can apply your data here:</p> <p><a href="https://github.com/lequysang/gitfiles02/blob/master/CollectionViewWithDecorationView.zip" rel="nofollow">https://github.com/lequysang/gitfiles02/blob/master/CollectionViewWithDecorationView.zip</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload