当我更改statusBarOrientation时,应用程序生命周期出错

时间:2018-04-19 04:45:36

标签: ios swift notifications

当我致电UIApplication.shared.setStatusBarOrientation(.landscapeRight, animated: true)

app进入后台并返回,打印

“ApplicationWillResignActive”

“ApplicationDidBecomeActive”

“ApplicationWillResignActive”

“ApplicationDidBecomeActive”

为什么?我只有两个动作

@objc fileprivate func handleApplicationWillResignActive() {
    debugPrint("ApplicationWillResignActive")
    if self.playerPlayStatus == .playing {
        self.currentPlayTime = self.player.currentTime()
        self.player.pause()
    }
}

@objc fileprivate func handleApplicationDidBecomeActive() {
    debugPrint("ApplicationDidBecomeActive")
    switch self.playerPlayStatus {
        case .pause:
            self.player.seek(to: self.currentPlayTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero, completionHandler: { (finished) in
                if finished {
                    self.player.play()
                }
            })
        default: break
    }
}

1 个答案:

答案 0 :(得分:0)

ApplicationWillResignActive和Background都是不同的东西。即使在前台应用程序中的应用程 请详细说明,你想做什么?