I am using UItableView
as a base for a user profile page. I have several custom cells. The first custom cell is images wrapped in scrollview
. I have this error when I open this view:
"<SnapKit.LayoutConstraint:[email protected]#143 UIScrollView:SCROLL_VIEW.top == Lez.ProfileImagesCell:0x12a02e800.top>",
"<SnapKit.LayoutConstraint:[email protected]#144 UIScrollView:SCROLL_VIEW.height == 512.0>",
"<SnapKit.LayoutConstraint:[email protected]#145 UIScrollView:SCROLL_VIEW.bottom == Lez.ProfileImagesCell:0x12a02e800.bottom - 16.0>",
"<NSLayoutConstraint:0x1c0094690 'UIView-Encapsulated-Layout-Height' Lez.ProfileImagesCell:0x12a02e800'ProfileImagesCell'.height == 44 (active)>"
And here is a custom code for this cell:
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")
}
}
I assume there is something wrong with height, but I can't solve this. Any input is appretiated.
Reason behind this conflict UIView-Encapsulated-Layout-Height
is initial height of the cell , you can try to set the priority of the bottom constraint of the scrollView to 999 , I mean this one
make.bottom.equalToSuperview().inset(16)