ios - 如何使用自动布局创建具有设置高度 subview 的 UITableViewCell?

标签 ios uitableview cocoa-touch ios-autolayout

我有一个表格 View 单元格(黄色)和一个 subview (红色):

subview 的高度应固定为 100。并且单元格的边框应为顶部 5 和底部 5。

表格行需要是动态的:

table.rowHeight = UITableViewAutomaticDimension
table.estimatedRowHeight = 110

我尝试过的:我将 subview 的高度设置为 100,并将顶部和底部设置为距离父 View 5。但是 Interface Builder 提示缺少 Y 位置或高度约束。

我想要完成的就是这个。 5 在顶部。 5 在底部。红景 = 100。 我该如何解决这个问题? enter image description here

编辑:这是示例文件 -> https://github.com/patchthecode/Autolayout

最佳答案

将 center y align 添加到 super view(cell) 将满足界面构建器。

关于ios - 如何使用自动布局创建具有设置高度 subview 的 UITableViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47719744/

相关文章:

ios - 如何在 iOS 中有条件地为 Storyboard转场设置动画?

ios - 如何将 Firebase 数据存储在数组中并打印出来?

ios - 隐藏不构成条件的单元格的更好方法(UITableView)

objective-c - 无法识别的选择器发送到实例 - UITableView 和 Restkit LoadObjects 选项

objective-c - 从坐标中获取当前地名(在 nsstring 中)

ios - 进入地理围栏且此时无网络连接时发送请求

ios - 强引用循环 : closures vs methods

ios - NSFetchedResultsController - 反转 NSIndexPath 与乘法部分和分页

ios - iOS项目中的冲突库

ios - UITableview 在重新加载时滚动到顶部太高了吗?