我想在单元格中创建一个通常的horizo​​ntalScrolling flowLayout UICollectionView,其中包含estimateItemSize和preferredLayoutAttributesFittingAttributes。但最后一个单元格有问题。任何想法在哪里?

Project itself

@implementation RowCollectionView

- (instancetype) initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout

{

if (self = [super initWithFrame:frame collectionViewLayout:layout])

{

[self configureRowCollectionView];

}

return self;

}

- (void) awakeFromNib

{

[super awakeFromNib];

[self configureRowCollectionView];

}

- (void) configureRowCollectionView

{

self.backgroundColor = [UIColor lightGrayColor];

self.dataSource = self;

self.delegate = self;

// Horizontal Direction

UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *) self.collectionViewLayout;

flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;

// Estimated Item Size

flowLayout.estimatedItemSize = CGSizeMake(self.bounds.size.height, self.bounds.size.height);

[self registerClass:[RowCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([RowCollectionViewCell class])];

}

- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

{

return 10;

}

- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

{

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([RowCollectionViewCell class]) forIndexPath:indexPath];

cell.contentView.backgroundColor = [UIColor redColor];

return cell;

}

@end

@implementation RowCollectionViewCell

- (UICollectionViewLayoutAttributes *) preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes

{

[super preferredLayoutAttributesFittingAttributes:layoutAttributes];

UICollectionViewLayoutAttributes *attributes = [layoutAttributes copy];

attributes.size = CGSizeMake(80, 80);

return attributes;

}

@end

ios 获取最后一个cell_ios – UICollectionView estimatedItemSize – 最后一个单元格未对齐...相关推荐

  1. iOS开发UICollectionView拖拽移动单元格

    一.介绍 iOS9提供API实现单元格排序呢功能,使用UICollectionView及其代理方法.iOS9之后有自带方法可以实现该效果,只需添加长按手势,实现手势方法和调用iOS9的API交换数据, ...

  2. VBA如何快速查找一个区域的右下角的那个单元格? 4种方法的比较

    问题:需要查找sheet中一个区域(a1所在range)的右下角单元格 目标:查找从range("A1")单元格开始的这个区域的右下角的单元格 应该是 cells(102,4) , ...

  3. elementUI 写一个表头列名、表体单元格样式、翻页器相对较为动态的表格el-table

    <template><!-- 表格---------------------------------------- --><div class="table&q ...

  4. excel表格行列显示十字定位_excel如何设置点击任意一个单元格会出现一个十字架标明所点击单元格的横和列...

    展开全部 按ALT+F11,输入如下代码(建议复制粘贴,不易出现手误):Private Sub Worksheet_SelectionChange(ByVal Target As Range) If  ...

  5. 2.7 实现强大的单元格左右滑动效果并添加功能按钮 [iOS开发中的神兵利器]

    原文:http://coolketang.com/staticCoding/5a995103d50eee2ea30512f9.html 1. 您将在本节课对单元格进行扩展,当鼠标在单元格左右滑动时,弹 ...

  6. iOS:多个单元格的删除(方法二):

    前面介绍了万无一失的方法一,这里介绍删除单元格的第二种方式,通过删除单元格中的内容的方式进行操作:(但是这种情况有一个小的弊端,由于单元格重用机制,如果单元格内容一样时,标记的存在会造成误删) 删除前 ...

  7. iOS开发那些事--自定义单元格实现

    自定义单元格 当苹果公司提供给的单元格样式不能我们的业务需求的时候,我们需要自定义单元格.在iOS 5之前,自定义单元格可以有两种实现方式:代码实现和用xib技术实现.用xib技术实现相对比较简单,创 ...

  8. 具有多个单元格类型的iOS UITableView

    In this tutorial, we'll be developing an iOS Application using Swift that has a single iOS UITableVi ...

  9. excel动态获取sheet页单元格内容

    1.问题描述 如下图所示,名称列可能是动态赋值的,名称列的内容有对应新的sheet页,如名称为PJ1及其PJ1的sheet页,最终需要获取PJ1的sheet页的B1单元格的内容. 如下图所示,是要获取 ...

  10. 2022-01-19:青蛙过河。 一只青蛙想要过河。 假定河流被等分为若干个单元格,并且在每一个单元格内都有可能放有一块石子(也有可能没有)。 青蛙可以跳上石子,但是不可以跳入水中。 给你石子的位置列

    2022-01-19:青蛙过河. 一只青蛙想要过河. 假定河流被等分为若干个单元格,并且在每一个单元格内都有可能放有一块石子(也有可能没有). 青蛙可以跳上石子,但是不可以跳入水中. 给你石子的位置列 ...

最新文章

  1. Master Data makes SAP Retail special
  2. javascript dom追加内容的例子
  3. YBTOJ:幻灯片(二分图匹配)
  4. QString 的使用技巧
  5. a href=javascript:;/a
  6. C#与Javascript变量、函数之间的相互调用
  7. [POJ3020]Antenna Placement(二分图最大匹配,最小边覆盖)
  8. 最简单的又炫的快捷菜单....喜欢的拿起就跑
  9. 读取QQ ClientKey C++版本
  10. linux统计单拷贝基因家族,为什么所有病毒基因都是单拷贝
  11. 捷径|皮皮虾去水印教程
  12. 音频线是什么 音频线如何连接
  13. 如何设计报表?手把手教你5步轻松制作报表
  14. 这套ai的思维让我感到了一个细思极恐的开源项目
  15. Linux下的lds链接脚本详解
  16. 外文翻译原文附在后面_外文翻译及外文原文(参考格式).doc
  17. java创建response对象_创建一个HttpResponse对象
  18. 为什么 transform-style: preserve-3d;不起效果
  19. 推荐一款隐藏托盘图标的软件
  20. centos7.8 安装部署 k8s 集群

热门文章

  1. Idea 中使用Lombok 编译报找不到符号
  2. mysql中exists 和 in的用法你还真不知道
  3. 【避坑】初次接项目的血与泪,扎坑了老铁(二)
  4. Android 自定义标题栏(title栏)
  5. 解决启用GTID binlog新安装完的MySQL提示无法登录
  6. HDU多校练习第一场4608——I_Number
  7. malloc和new的区别和联系
  8. AIX ksh使用小技巧
  9. java 使用 poi 操纵 excel2003 经验总结
  10. int.Parse(),int.TryParse(),Convert.ToInt32(), (int)转换为数字类型方法简介