ios - UICollectionView swift 中的一个自定义单元格

标签 ios swift uicollectionview uicollectionviewcell uicollectionviewlayout

我的应用程序中有一个页面,顶部有一个 slider ,底部有一个重复列表。现在我正在寻找一种解决方案,可以使用单个 UICollectionView 完成整个 UI,是否可以让单个单元格具有自定义设计和来自其他单元格的数据源?

这是我的设计: enter image description here

或者我应该分别使用两个不同的 UICollectionView 吗?最好的解决方案是什么?

另外,我以编程方式创建了 UI。不是 Storyboard。

最佳答案

正如我在评论中提到的,你必须接受

  1. 一个 Collection View
  2. 两个部分

在第一节通过项目:1

第二部分中的传递项:数组计数

画廊这里是示例代码

    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]];
    }

关于ios - UICollectionView swift 中的一个自定义单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42620965/

相关文章:

ios - 在使用 Storyboard 和 segue 时打开它之前选择 tabbarcontroller 的默认选项卡

ios - UISegmentedControl 与 UICollectionView 错误与 Switch 语句

ios - 代码/iOS : does Maps need to be switched on in Capabilities?

ios - iOS 应用程序警报和通知中的表情符号 - Xcode/Swift

swift - 在 Swift 类中使用指向对象的指针

ios - 如何在已经是 NIB 的 UICollectionViewCell 中加载带有自定义单元格的 UITable

ios - 使用 AVFoundation 访问图像和音频

ios - UIViewController 未加载

ios - UICollectionView 中的单元格间距

ios - 选择时的动画项目