Per*_*tor 3 uitableview ios uitableviewautomaticdimension
所以,我的表视图显示图像.每个细胞基本上都是填满整个细胞的图像contentView.由于图像具有不同的宽高比,我需要我的单元格根据表格视图宽度和图像的纵横比调整其高度.我遵循了这个Ray Wenderlich教程但现在遇到了约束冲突.通过改变imageViews高度约束来调整图像的大小myImageViewHeight.constant = tableView.frame.width / aspectRatio
2016-06-16 13:56:25.823 MyApp[92709:5649464] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x7fbcdaf5c190 V:[UIImageView:0x7fbcdaf5c300(303)]>",
"<NSLayoutConstraint:0x7fbcdaf5b460 V:|-(0)-[UIImageView:0x7fbcdaf5c300] (Names: '|':UITableViewCellContentView:0x7fbcdaf52230 )>",
"<NSLayoutConstraint:0x7fbcdaf5b4b0 V:[UIImageView:0x7fbcdaf5c300]-(0)-| (Names: '|':UITableViewCellContentView:0x7fbcdaf52230 )>",
"<NSLayoutConstraint:0x7fbcdaf5e550 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fbcdaf52230(100)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fbcdaf5c190 V:[UIImageView:0x7fbcdaf5c300(303)]>
Run Code Online (Sandbox Code Playgroud)
图像视图具有以下约束,并且单元格contentView为superview.
在表视图控制器类中,我正在使用
self.tableView.estimatedRowHeight = 80
self.tableView.rowHeight = UITableViewAutomaticDimension
Run Code Online (Sandbox Code Playgroud)
我也试过这个 - 同样的结果.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Run Code Online (Sandbox Code Playgroud)
我猜我必须摆脱'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fbcdaf52230(100)]>"但如何?另外,是否有人知道如何使用动态内容正确创建表视图的某些文档/教程,这些内容不仅涵盖了单元格中的一堆标签?如果图像视图被标签替换,我的代码工作得很好......
| 归档时间: |
|
| 查看次数: |
2044 次 |
| 最近记录: |