UICollectionView swift中的一个自定义单元格(One custom cell in UICollectionView swift)

系统教程 行业动态 更新时间:2024-06-14 16:57:17
UICollectionView swift中的一个自定义单元格(One custom cell in UICollectionView swift)

我的应用程序中有一个页面,顶部有一个滑块,底部有一个重复的列表。 现在我正在寻找一个可以通过单个UICollectionView整个UI中完成的解决方案,是否可以从其他单元格中获得具有自定义设计和dataSoruce的单个单元格?

这是我的设计:

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

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

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:

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

Also, I created UI programmatically. is not Storyboard.

最满意答案

正如我在评论中提到的,你必须采取

一个集合视图 两节

第一节通过项目: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]]; }

As I mentioned in comment you have to take

One collection view 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]]; }

更多推荐

本文发布于:2023-04-12 19:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/ef039e9cb15a5914d51b534548f77e1a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   单元格   swift   UICollectionView   custom

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!