我正在编写一个ViewController,用于控制在特定方向上工作的约束,在方向更改时更改其常量。
但是当Application resignActive
屏幕改变方向两次时,所以约束工作很奇怪。
代码:
private func updateforecourtHeightConstraint() {
// TODO: This function just work for portrait orientation 'cause ios change orientation during resignActive/becomeActive
let screenPortraitHeight = UIScreen.mainScreen().bounds.height > UIScreen.mainScreen().bounds.width ? UIScreen.mainScreen().bounds.height : UIScreen.mainScreen().bounds.width
forecourtHeightConstraint.constant = screenPortraitHeight - 80
rootTableView.contentInset = UIEdgeInsetsMake(forecourtHeightConstraint.constant, 0, 0, 0)
print(UIApplication.sharedApplication().statusBarOrientation.isPortrait)
}
在iPad Mini 2设备输出上
#App started
true
true
#resignActive
false
true
#resignActive
false
true
由于