2

我正在UItableView用作用户个人资料页面的基础。我有几个自定义单元格。第一个自定义单元格是包裹在scrollview. 打开此视图时出现此错误:

"<SnapKit.LayoutConstraint:0x1c42a2940@CardFullscreenViewController.swift#143 UIScrollView:SCROLL_VIEW.top == Lez.ProfileImagesCell:0x12a02e800.top>",
"<SnapKit.LayoutConstraint:0x1c02a9180@CardFullscreenViewController.swift#144 UIScrollView:SCROLL_VIEW.height == 512.0>",
"<SnapKit.LayoutConstraint:0x1c02a91e0@CardFullscreenViewController.swift#145 UIScrollView:SCROLL_VIEW.bottom == Lez.ProfileImagesCell:0x12a02e800.bottom - 16.0>",
"<NSLayoutConstraint:0x1c0094690 'UIView-Encapsulated-Layout-Height' Lez.ProfileImagesCell:0x12a02e800'ProfileImagesCell'.height == 44   (active)>"

这是此单元格的自定义代码:

class ProfileImagesCell: UITableViewCell {
    var scrollView = UIScrollView()

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupScrollView()
        layoutIfNeeded()
    }

    private func setupScrollView() {
        addSubview(scrollView)
        let x = frame.width * 1.6
        scrollView.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(x)
            make.bottom.equalToSuperview().inset(16)
        }
        scrollView.snp.setLabel("SCROLL_VIEW")
        scrollView.auk.settings.contentMode = .scaleAspectFill
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

我认为高度有问题,但我无法解决这个问题。任何输入都会被欣赏。

4

1 回答 1

2

这个冲突背后的原因UIView-Encapsulated-Layout-Height是单元格的初始高度,您可以尝试将scrollView的底部约束的优先级设置为999,我的意思是这个

make.bottom.equalToSuperview().inset(16)
于 2018-03-24T16:11:39.150 回答