小编Ste*_*ean的帖子

从UITableView中删除以编程方式定制的UITableViewCell时,约束会中断

我正在使用UITableViewController,我正在加载自定义UITableViewCell.单元中的所有元素和约束都以编程方式配置.TableView看起来像这样

在此输入图像描述 除删除单元格外,所有操作都很完美.我将tableView配置为在删除时淡出单元格.然而,单元格给出一个小的混蛋移动然后它向左而不是褪色,我在控制台中得到自动布局错误消息:"无法同时满足约束"下面

"<NSLayoutConstraint:0x600002551a40 UIView:0x7fccbd5286f0.height == 100   (active)>",
"<NSLayoutConstraint:0x6000025505a0 V:|-(16)-[UIView:0x7fccbd5286f0]   (active, names: '|':UITableViewCellContentView:0x7fccbd541b10 )>",
"<NSLayoutConstraint:0x600002550730 UIView:0x7fccbd5286f0.bottom == UITableViewCellContentView:0x7fccbd541b10.bottom   (active)>",
"<NSLayoutConstraint:0x6000025605a0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fccbd541b10.height == 1.19209e-07   (active)>"
Run Code Online (Sandbox Code Playgroud)

以下

"<NSLayoutConstraint:0x6000025505a0 V:|-(16)-[UIView:0x7fccbd5286f0]   (active, names: '|':UITableViewCellContentView:0x7fccbd541b10 )>",
"<NSLayoutConstraint:0x600002550730 UIView:0x7fccbd5286f0.bottom == UITableViewCellContentView:0x7fccbd541b10.bottom   (active)>",
"<NSLayoutConstraint:0x6000025605a0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fccbd541b10.height == 1.19209e-07   (active)>"
Run Code Online (Sandbox Code Playgroud)

并且"将试图通过打破约束来恢复"以下

<NSLayoutConstraint:0x600002551a40 UIView:0x7fccbd5286f0.height == 100   (active)>
<NSLayoutConstraint:0x600002550730 UIView:0x7fccbd5286f0.bottom == UITableViewCellContentView:0x7fccbd541b10.bottom   (active)>
Run Code Online (Sandbox Code Playgroud)

我将控制台输出分成几部分,因为我无法将它们全部粘贴在一起.

基本上,我在单元格内部有一个UIViewcellView(白色圆角区域)contentView.你看到的所有其他元素都在里面cellView.我在cellView和之间应用了以下约束contentView

cellView.translatesAutoresizingMaskIntoConstraints = false
cellView.heightAnchor.constraint(equalToConstant: 100).isActive = true
cellView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: …
Run Code Online (Sandbox Code Playgroud)

uitableview ios autolayout swift

3
推荐指数
1
解决办法
1152
查看次数

标签 统计

autolayout ×1

ios ×1

swift ×1

uitableview ×1