This question already has an answer here:
- App crashed in iOS 6 when user changes Contacts access permissions 2 answers
I have a collection view (standard flow layout) where the first cell is displaying a live camera feed, and the rest of the cells are displaying photos from the user's library using iOS 8's new Photos Framework. Everything renders and works great.
When opening for the first time, I'm prompted for access to the Camera and to the Photos library, as expected. My app behaves fine if I select yes or no for either of the prompts.
However, if I background the app, go into Settings > Privacy > Photos|Camera and toggle access, my app crashes. When connected to Xcode, I don't get any feedback for why the app is crashing.
Unfortunately, Apple's Photos Framework examples app does the same thing.
How can I prevent this from happening? I've subscribed to notifications for AVCaptureDeviceWasConnectedNotification
, AVCaptureDeviceWasDisconnectedNotification
, and registerChangeObserver
on PHPhotoLibrary
but those never seem to get called.
Again, here are the steps using Apple's Sample app and the Simulator:
- In the Simulator, go to Settings > General > Reset > Reset Location & Privacy
- Run the app
- Allow the app access to your photos library
- Background the Sample App and open Settings
- Go to Privacy > Photos and toggle the setting off
- Watch Xcode crash
In step 3, if you decline access to your photos, and in step 5, enable access, the app will also crash.