gpt4 book ai didi

ios - 当设备旋转改变时创建附加约束

转载 作者:搜寻专家 更新时间:2023-10-31 23:06:45 25 4
gpt4 key购买 nike

我有一个 subview ,它的约束通过 IBOutlet 引用了 super View ,我正在通过停用它来更改约束,然后赋予新值并再次激活,这工作正常并且没有警告但是当设备旋转和似乎添加了另一个约束(我在 Storyboard 中添加的约束)代码:

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 )>"

底 View Storyboard约束 enter image description here

最佳答案

你在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()

关于ios - 当设备旋转改变时创建附加约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52950181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com