Been using AVCaptureSession to record barcodes, and it works well. I also have followed the advice on stack overflow (How to properly release an AVCaptureSession) to
[_session stopRunning];
[_prevLayer removeFromSuperlayer];
_prevLayer = nil;
_session = nil;
in ViewWillDisappear, with the hope that it properly releases the CaptureSession. (Other answers in SO refer to pre ARC time)
However, when I toggle the camera privacy settings for the App (E.g. from enabled to disabled, or vice versa), the App crashes. This is a problem because a user that doesn't originally enable Camera cannot do it retrospectively without it crashing. Is there anything else I need to do to prevent this from happening?
Thanks much!
No, there is nothing to do about this; this behavior will always cause the app to crash. The same thing occurs when you enable/disable Privacy options for letting an app search the iOS contact book, etc. If the user declines the initial Privacy request, and minimizes the app and goes to the Settings app and changes the Privacy setting, you will see that the app relaunches the next time you come back to it. This occurs any time you make a change to a Privacy setting for your respective app.
来源:https://stackoverflow.com/questions/24793090/prevent-avcapturesession-from-crashing-once-user-toggles-camera-privacy-settings