Dark star
Dark star

Reputation: 5832

One custom cell in UICollectionView swift

I have a page in my App with a slider on top and a repeated list on the bottom. now I'm looking for a solution that can be done this entire UI with a single UICollectionView, is that possible to have a single cell with custom design and dataSoruce from other cells?

Here is my design: enter image description here

Or should I use tow different UICollectionView separately? what is the best solution out there?

Also, I created UI programmatically. is not Storyboard.

Upvotes: 0

Views: 372

Answers (1)

Prashant Tukadiya
Prashant Tukadiya

Reputation: 16446

As I mentioned in comment you have to take

  1. One collection view
  2. Two Sections

In section one pass items : 1

In Section two pass items: Array count

gallery here is sample code

    GalleryCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kGalleryCell forIndexPath:indexPath];
    if (cell.gestureRecognizers.count <= 0) {
        UISwipeGestureRecognizer *swipeNext = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(cellDidSwipe:)];
        swipeNext.direction = UISwipeGestureRecognizerDirectionLeft;

        UISwipeGestureRecognizer *swipePrev = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(cellDidSwipe:)];
        swipePrev.direction = UISwipeGestureRecognizerDirectionRight;

        [cell setGestureRecognizers:@[swipeNext,swipePrev]];
    }

Upvotes: 1

Related Questions