如何在ios中的自定义UITableViewCell中添加轮播视图

问题描述 投票:0回答:3

我是ios新手,所以在表格单元格视图中添加轮播视图变得非常困难。请帮助我在自定义表格单元格视图中添加轮播视图。enter image description here

我想要像上面这样的轮播视图。这是一个表格单元格,其中左侧是他们的个人资料照片,右侧是他们的轮播视图,其中多个图像将是他们的。所以请帮助我如何做到这一点。

ios objective-c cocoa-touch icarousel
3个回答
2
投票

看看http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/ 它描述了如何将 UICollectionView 添加到表视图单元格


0
投票

如果您现在知道如何添加轮播视图,这仍然不是一个大问题。

在 ViewController 中,这是方法中的 TableView 委托

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

只需添加“if”状态来定义单元格应具有哪种类型并在那里执行所有其他操作。像这样

 if (indexPath.row == 0) {
 NSString *labelCellIdentifier = @"CellWithLabelIdentifier";
 CellWithLabel *cell == (CellWithLabel *)[tableView dequeueReusableCellWithIdentifier:labelCellIdentifier];

 //do your things

 } else if (indexPath.row == 1) {
 NSString *carouselCellIdentifier = @"CellWithCarouselIdentifier";
 CellWithCarousel *cell == (CellWithCarousel *)[tableView dequeueReusableCellWithIdentifier:carouselCellIdentifier];

 //do your things

 }

附注如果这个方法变得很大,请记住将您的代码明智地放入多个方法中,以便稍后了解代码中发生的情况


0
投票

尝试CardCarousel,它是一个轮播库,使用方式如下:

CardCarousel(frame: frame)
    .cardLayoutSize(widthDimension: .fractionalWidth(0.7), heightDimension: .fractionalHeight(0.7))
    .cardTransformMode(.liner)
    .move(to: contentView)
© www.soinside.com 2019 - 2024. All rights reserved.