[英]additional constraint is created when device rotation changes
我有一个子视图,其约束通过IBOutlet引用超级视图,我通过停用它然后给出新值并再次激活来改变约束,这工作正常,没有警告,但问题发生在设备旋转时,它似乎另一个约束被添加(我在故事板中添加的约束)代码:
bottomViewBottomConstraint.isActive = false
if self.isHide {
bottomViewBottomConstraint = bottomView.bottomAnchor.constraint(equalTo: playerView.bottomAnchor,constant:0)
}
else {
bottomViewBottomConstraint = bottomView.bottomAnchor.constraint(equalTo: playerView.bottomAnchor,constant:bottomView.frame.height + 50)
}
bottomViewBottomConstraint.isActive = true
轮换后警告:
"<NSLayoutConstraint:0x600003fdce60 UIView:0x7fc034f050b0.bottom == PlayKit.PlayerView:0x7fc034f69870.bottom + 143.333 (active)>", "<NSLayoutConstraint:0x600003fe3480 'bottomViewId' V:[UIView:0x7fc034f050b0]-(0)-| (active, names: '|':PlayKit.PlayerView:0x7fc034f69870 )>"
你需要在viewDidLoad
它
var bottomViewBottomConstraint:NSLayoutConstraint!
bottomViewBottomConstraint = bottomView.bottomAnchor.constraint(equalTo: playerView.bottomAnchor,constant:0)
并且不断地玩耍
bottomViewBottomConstraint.constant = self.isHide ? 0 : bottomView.frame.height + 50
self.view.layoutIfNeeded()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.