在applicationDidBecomeActive()期间,Cocoa方向发生了变化,如何解决?

时间:2016-03-26 17:00:44

标签: ios swift cocoa

我正在编写一个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

由于

0 个答案:

没有答案