Brad The App Guy
Brad The App Guy

Reputation: 16275

UIImagePickerController in camera mode gets 'stuck' with the shutter closed

Occasionally in low-memory conditions the UIImagePickerController I use gets 'stuck' with the shutter closed. Generally when this the WatchDog is allready jettisoning other background apps so within a second or two the low memory condition is over, yet the UIImagePicker controller is still stuck.

Has anyone else encountered this and implemented any sort of workaround or found a way to detect when the picker is in this state, so that it can be removed and a new one put in its place.

Thoughts / Ideas / Solutions??

Upvotes: 6

Views: 1834

Answers (2)

JosephH
JosephH

Reputation: 37495

Have you tried allocating (and then freeing) a megabyte or two of memory using malloc() before starting the UIImagePicker? Or claim it slightly earlier in your app, and then release it when you want to show the picker.

I guess you should be able to see roughly the amount of memory UIImagePicker needs to run successfully by running your app inside of instruments.

Whilst not ideal, it should cause other apps to be given memory warnings earlier on and hence the UIImagePicker should then have enough memory to run.

Upvotes: 2

VdesmedT
VdesmedT

Reputation: 9113

That's a known behavior of the camera application too. I guess you can't do anything to it except freeing as much memory as you can before starting it. You could raise a memoryWarning yourself so every application will receive it and start freeing memory but I have no idea how I can do that. I started investigate sending the notification myself (UIApplicationDidReceiveMemoryWarningNotification) without success. I guess we need to send an object along the notification to define the warning level but I'm really not sure.

Upvotes: 0

Related Questions