I implemented the camera using the AVFoundation framework introduced in iOS 4 and 5, but ran into an inconsistent problem using the captureStillImageAsynchronouslyFromConnection:completionHandler:
function, where the completion handler block is never called. The shutter sound does not work, and the preview freezes in this situation.
I followed both Apple (WWDC 2010 and 2011 videos) and non-Apple manuals (blogs and SO posts) to implement still image capture when resolving photos without any improvement. I was able to reproduce somewhat sequentially under the following conditions :
- If I install flash on
AVCaptureFlashModeAuto
and take pictures in low light, it freezes and never starts the completion block. The flash fires, but the shutter sound does not work. With the same code, I can take a picture in normal lighting, when the shutter sound fires, the flash does not work, and the completion block is executed. - If I have not installed
flashMode
or disabled it, I can take a few shots, but after a small number (usually from 1 to 5), the completion block stops shooting. To clarify the scenario may be:- Take a picture and view the confirmation screen.
- Return to the photo screen.
- Repeat 1 and 2 a couple of times
- Click the snapshot and it freezes in front of the completion block.
My implementation
I have an interface processed in ViewController and a separate class for processing all AVFoundation material. An instance variable of a single class that processes AVFoundation files is located in the ViewController. This differs from the implementation of the example, but I do not understand why this should cause such a random error.
Additional observations
- Even when checking
[stillImageOutput isCapturingStillImage]
it will continue to return false and continue to execute the captureStillImageAsynchronouslyFromConnection
function - If I switch to another application, block the phone, follow some other actions in the application or tap the “Take Photo” button a million times. I can get a completion block to return an error. They are different depending on what kind of action. Common are 11800, 11801 and 11830. They do not seem to be related to freezing.
- I let our test phone (iPhone 4 GSM) sit for an hour to see if this would end. No dice.
I would really like to know if there is something that I could lose, the property remained inappropriate or a known problem when working.
Thanks.
(I saw a similar post, but none of the answers solved my problem. I need a res photo in the application. For reference: iPhone SDK 4 AVFoundation - How to use captureStillImageAsynchronouslyFromConnection correctly? )
source share