How can I prevent iOS apps from resetting after changing Camera permissions?

前端 未结 2 1415
独厮守ぢ
独厮守ぢ 2020-12-14 19:47

Currently, when I change the camera permissions for my app in Settings, then navigate back to my app, the app will force a refresh and I will lose my place in the app. I fol

2条回答
  •  春和景丽
    2020-12-14 20:23

    The accepted answer is correct, however the workaround does not appear to work in the current version of iOS (9.2) - the application seems to terminate before UIApplicationWillTerminateNotification is fired. However by listening to UIApplicationDidEnterBackgroundNotification, the same can be achieved. e.g in Swift, put this in viewDidLoad()

    NSNotificationCenter.defaultCenter().addObserver(self, selector: "enteringBackground:", name: UIApplicationDidEnterBackgroundNotification, object: nil)
    

    and have a function like this:

    func enteringBackground(sender:AnyObject){
        // Save application state here
    }
    

提交回复
热议问题