简体   繁体   English

UICollectionView中的一个自定义单元格

[英]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? 现在,我正在寻找一种可以通过单个UICollectionView完成整个UI的解决方案,是否可以将单个单元格与其他单元格一起进行自定义设计和dataSoruce?

Here is my design: 这是我的设计: 在此处输入图片说明

Or should I use tow different UICollectionView separately? 还是应该分别使用两个不同的UICollectionView what is the best solution out there? 最好的解决方案是什么?

Also, I created UI programmatically. 另外,我以编程方式创建了UI。 is not Storyboard. 不是情节提要。

As I mentioned in comment you have to take 正如我在评论中提到的,您必须

  1. One collection view 一个收藏夹视图
  2. Two Sections 两节

In section one pass items : 1 在第一部分中,合格项目: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]];
    }

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

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