在编辑模式下,UITableViewCell中的UIImageView布局不正确

时间:2018-11-15 13:46:37

标签: ios uitableview uikit

我有一个相当简单的UITableViewCell

enter image description here

没什么特别的,但是我遇到了一个问题。每当启用编辑模式时,UIImageView的位置和大小都会改变,完全忽略将其固定在其超级视图边缘的约束(蓝色背景):

enter image description here

超级视图的布局正确:

enter image description here

我希望在系统日志中看到有关打破约束的消息,但没有任何内容。

为什么会发生这种情况以及如何解决?

这是一个再现问题的项目:https://www.icloud.com/iclouddrive/0NvLeUettZub5uQIXUM4p0bGw#TestApp


编辑:在激活编辑模式后,我尝试在图像容器上调用layoutIfNeeded()

class NoteTableViewCell: UITableViewCell {

    override func setEditing(_ editing: Bool, animated: Bool) {
        super.setEditing(editing, animated: animated)
        noteImageView.superview?.layoutIfNeeded()
    }
}

即使我没有启用编辑模式,现在布局也不正确。

编辑2: @Desdenova建议,这可能是由水平UIStackView引起的,但是用等效约束代替它并不能解决问题。

0 个答案:

没有答案