나는 사용자의 목록을 세포(컬렉션 보기 목록 cell)기반으로, 이 문서. 나는 수동으로 추가의 높이로 보기에 세포이지만,저는 경고를 아래 콘솔에서의 엑스 코드,그리고 확실하지 않은 부분을 해결할 수 있습니다.
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x281209220 h=--& v=--& liveTest.LiveChannelContentView:0x128c13430.height == 44 (active)>",
"<NSLayoutConstraint:0x2812371b0 UIView:0x128c136b0.height == 60 (active)>",
"<NSLayoutConstraint:0x2812372a0 V:|-(0)-[UIView:0x128c136b0] (active, names: '|':liveTest.LiveChannelContentView:0x128c13430 )>",
"<NSLayoutConstraint:0x2812372f0 UIView:0x128c136b0.bottom == liveTest.LiveChannelContentView:0x128c13430.bottom (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x2812371b0 UIView:0x128c136b0.height == 60 (active)>
아래 코드는 내가 이 오류 메시지가 표시됩니다.
class LiveChannelContentView: UIView, UIContentView {
let contentsView = UIView()
lazy var titleLabel: UILabel = {
let label = UILabel()
label.text = ""
return label
}()
lazy var statusLabel: UILabel = {
let label = UILabel()
label.text = ""
return label
}()
lazy var symbolImageView: UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
return imageView
}()
var liveEvent: LiveEvent?
init(configuration: LiveChannelContentConfiguration) {
// Custom initializer implementation here.
super.init(frame: .zero)
print("this is the view height: \(self.bounds.height)") // -> I get 0.0 in here
setupAllViews()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupAllViews() {
addSubview(contentsView)
contentsView.addSubview(symbolImageView)
contentsView.addSubview(indicator)
contentsView.addSubview(titleLabel)
contentsView.addSubview(statusLabel)
contentsView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
contentsView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
contentsView.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
contentsView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
contentsView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor),
contentsView.heightAnchor.constraint(equalToConstant: 60)
])
contentsView.backgroundColor = .yellow
symbolImageView.centerY(leading: contentsView.leadingAnchor, trailing: nil, parent: contentsView, paddingLeft: 0, paddingRight: 0, size: CGSize(width: 50, height: 50))
indicator.centerY(leading: contentsView.leadingAnchor, trailing: nil, parent: contentsView, paddingLeft: 0, paddingRight: 0, size: CGSize(width: 50, height: 50))
titleLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: symbolImageView.trailingAnchor, constant: 8),
titleLabel.topAnchor.constraint(equalTo: symbolImageView.topAnchor),
titleLabel.trailingAnchor.constraint(equalTo: contentsView.trailingAnchor)
])
statusLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
statusLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor),
statusLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor),
statusLabel.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor)
])
print("this is the view after setup: \(self.bounds.height)") // I also get 0.0 in here
}
}
그래서,명확히하는 LiveChannelContentView 입니다,나는 추가 노란색 배경을 보기입니다. 두 가지가 있지 않다. 첫째,심지어 Xcode 말
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x2812371b0 UIView:0x128c136b0.height == 60 (active)>
면 스크린샷을 찍 응용 프로그램의 측정은 노란색 배경 UIView 의 높이를,그것은 여전히 60. 나는 생각 깨 제약 조건으로 사용되고 있는 다른 높이 제약 조건을 대신의 60,그러나 그것은 잘못입니까?
다른 것은 내가 궁금했는
"<NSAutoresizingMaskLayoutConstraint:0x281209220h=--&v=--&liveTest.LiveChannelContentView:0x128c13430.높이==44(active)>" 에서 사용되는 나의 코드입니다. 검색 파일 포함
44
내 작업 영역에서 그러나 나는 아무것도 건지지 못했습니다.
정말로 확실하지 않지만,나는 생각은 높이의 44 60 에 적용되는 동일한 UIView 및 Xcode 의 60 의 높이는 앵커 또는 무언가이다. 그러나 때,나는 삭제를 높이 앵커에 대한 contentsView, contentsView.heightAnchor.constraint(equalToConstant: 60)
,응용 프로그램으로 추락한 다음과 같다.
도 삭제하기 위쪽이나 아래쪽 앵커의 contentsView 지만,그것은 또한 분쇄니다.
contentsView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
나
contentsView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor),
그래서 말해 줄 수 있는 제약해야 나를 수정하거 하는건가요?