Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Camera Iris / Shutter stuck in closed position

As the title states the app that I am developing has an issue that is caused only when the app is relaunched after entering the background.

The camera iris or shutter gets stuck in the closed position. The funny thing is you can still take a picture but you cannot see the preview. Once the picture is taken, it is shown correctly in the view.

This issue does not happen when the app is launched if the app is completely closed. I can take pictures, add effects and so on, every time the camera is opened it works correctly.

Here are the exact steps to reproduce the issue:

1) I open the app, everything works fine.

2) The app enters the background either by pressing the home button or incoming call.

3) When the app enters the foreground / reopened and the camera is accessed the shutter screen is shown and remains closed in the stuck position.

4) The only way to fix it is to dismiss the modal view camera controller and press the camera button again.

I have done some research to find an answer and have come up with nothing. There are no memory leaks and I have checked the memory allocations in instruments and there is nothing unusual.

Hopefully someone has a solution, I appreciate the help.

Thank you in advance.

like image 353
dana0550 Avatar asked Nov 09 '11 00:11

dana0550


5 Answers

I'm having the exact same issue, but narrowed down a bit - it only happens with iOS 5. With some hints from other people talking about memory, I freed up as much memory as possible before presenting the UIImagePickerController and the problem stopped happening.

like image 189
SWoo Avatar answered Nov 05 '22 10:11

SWoo


I was having the same problem, running in an ARC project.

Press the camera button on my main screen, the imagePickerController would display, cancel the imagePickerController. Press the home button (close) the app. Come back to my app and press the camera button again. In this case the shutter would show and be stuck.

Using memory issues as the main clue - I found out that my overlay view had a strong reference to the imagePickerController. I changed this to a weak reference and the problem went away.

like image 27
user1262701 Avatar answered Nov 05 '22 11:11

user1262701


I think that when you have the problem, and try to take a photo with the Apple app, you have the problem there also. Isn't it ? If yes, you may restart the device to solve the problem. And apply dana's tip.

like image 5
Oliver Avatar answered Nov 05 '22 12:11

Oliver


When the app goes into background mode then you should dismiss the camera and represent it when the app regains focus.

like image 4
logancautrell Avatar answered Nov 05 '22 12:11

logancautrell


I was having the same problem , Following solutions works for me. whenever you are presenting UIImagePickerController modally. init it and release it after the use. Hope it works for you also .

self.imagePickerController = [[UIImagePickerController alloc] init];
self.imagePickerController.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    self.imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.imagePickerController.showsCameraControls = NO;

    self.imagePickerController.cameraOverlayView = cameraOverlayView;
} else {
    self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
}
[self presentViewController:imagePickerController animated:YES completion:^(void)
 {
   // If you want to do something extra
 }];
like image 2
Ankit Avatar answered Nov 05 '22 11:11

Ankit