[英]Swift : update of view constraints not visible
我确实有一个UIScrollView
,其中包含几个UIViewController
。 对于UIViewController
内部的元素,我使用了AutoLayout。 现在,如果当前设备是iPhone 4,我想更改视图约束的常量。因此,我重写了UIViewControllers
updateViewConstraints()
:
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
记录了正确的新常量,更新也不可见。 在实施过程中我需要更改什么?
正如解释在这里我不得不整合self.view.layoutIfNeeded()
前和更改视图contstraint不变之后。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.