【问题标题】:UITableView with embed UICollectionView is not working带有嵌入 UICollectionView 的 UITableView 不起作用
【发布时间】:2016-09-14 11:12:00
【问题描述】:

我有一个 UITableView,里面有 4 个 UITableViewCell。我希望它是动态的设置:

tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension

对于第三个单元格,嵌入 UICollectionView,它有 20 个 UICollectionViewCell。

当我运行我的项目时,uicollectionviewcell 返回 (44, 44) 并显示以下错误:

The behavior of the UICollectionViewFlowLayout is not defined because:
the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7fe028c25bd0>, and it is attached to <UICollectionView: 0x7fe029884800; frame = (20 0; 335 44); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60000024bbb0>; layer = <CALayer: 0x6000002269c0>; contentOffset: {0, 0}; contentSize: {0, 44}> collection view layout: <UICollectionViewFlowLayout: 0x7fe028c25bd0>.
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

提前致谢。

【问题讨论】:

  • 有什么问题?

标签: ios objective-c uitableview uicollectionview


【解决方案1】:

调试器告诉你出了什么问题:

帧 = (20 0; 335 44)

这是你的collectionView框架,这意味着collectionView的高度只有44px,这也是你的单元格的高度。所以它不适合带有单元格插入值的 collectionView...

检查您的 collectionView 框架和 autoLayout 约束

【讨论】:

    【解决方案2】:

    增加集合视图的高度或减小集合视图的单元格高度,因为集合视图的高度是44,单元格的高度也是44。您的单元格或项目的高度必须小于集合视图的高度!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多