gpt4 book ai didi

ios - swift : update of view constraints not visible

转载 作者:行者123 更新时间:2023-11-28 11:16:35 30 4
gpt4 key购买 nike

我确实有一个 UIScrollView,它包含几个 UIViewController。对于 UIViewController 中的元素,我使用了 AutoLayout。现在,如果当前设备是 iPhone 4,我想更改 View 约束的常量。所以我覆盖了 UIViewControllersupdateViewConstraints():

override func updateViewConstraints() {

if (self.view.frame.height == 480) {

self.imageMarginLeft.constant = 40
self.imageMarginRight.constant = 40
self.textMarginTop.constant = 10

println("updateViewConstraint \(self.imageMarginRight.constant)")
}

super.updateViewConstraints()
}

但即使 println 记录正确的新常量,更新也是不可见的。我必须在实现中更改什么?

最佳答案

如解释here在更改 View 约束常量之前和之后,我必须集成 self.view.layoutIfNeeded()

关于ios - swift : update of view constraints not visible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31372793/

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