ios - UITableViewAutomaticDimension 不适用于包含 tableView 的单元格

标签 ios swift uitableview swift3

我有一个包含 tableViewcell。我需要这个 tableView 来实现 datePicker 扩展行为,如下所示:

enter image description here

但我有这个:

enter image description here

我的代码非常简单。在这两个 tableView 中,我都将 estimatedRowHeightrowHeight 设置为 UITableViewAutomaticDimension(在这种情况下,我得到了第二个 gif 显示的结果。通过手动将 heightForRowAtIndexPath 设置为特定高度值实现的预期结果(第一个 git)。但是我得到了我没有预料到的结果。
此外,当我运行该应用程序时,我会收到以下警告:

[Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.

为什么会这样?并且可以通过不添加新的开销代码来完成这项工作(例如,我相信如果我使用 intrinsic size 做一些魔术,UITableViewAutomaticDimension 将正确工作)。

附言这是 the demo project .

最佳答案

如果您正在使用 UITableViewAutomaticDimension,您需要设置单元格中所有元素的约束,从上、左、下、右。如果您不这样做,那么您将收到问题中显示的警告。

关于ios - UITableViewAutomaticDimension 不适用于包含 tableView 的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40693246/

相关文章:

iOS MapBox map 滞后

ios - Firebase 数据库结构

iphone - 删除行时崩溃

ios - PHFetchResults 日期过滤器没有为时间范围生成正确的结果

iOS 如何为来自 CollectionView 的图像上的 UIPreviewActions 确认 'Delete'

ios - AudioKit 多个 AKMIDISampler

ios - 如何优化 UIPageViewController 使其具有类似于 tableView.dequeueReusableCell(withIdentifier :for:)?

iphone - drawRect 中的可拉伸(stretch)图像导致滚动缓慢

ios - swift 中嵌套字典 API 的结构

iphone - 如何根据条件语句抓取列表项?