【问题标题】:How to add carousel view inside custom UITableViewCell in ios如何在ios中的自定义UITableViewCell中添加轮播视图
【发布时间】:2014-12-18 11:45:01
【问题描述】:

我是 ios 新手,因此在表格单元格视图中添加轮播视图变得非常困难。请帮我在自定义表格单元格视图中添加轮播视图。

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

【问题讨论】:

标签: ios objective-c cocoa-touch icarousel


【解决方案1】:

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

【讨论】:

  • 是的,我看到了,但是我想添加标签并在它旁边添加轮播视图
【解决方案2】:

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

在 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

 }

附:记住,如果这个方法变得很大,以便以后理解你的代码中发生了什么,请记住明智地把你的代码放在多个方法中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-13
    相关资源
    最近更新 更多