UIImagePickerController Example

27 Jan

I was having a hard time finding recent information on using the UIImagePickerController for iOS.  With iOS 4.2 the camera appears to use more memory and quite frequently causes memory warnings to fire.  When these warnings fire your view and all outlets are set to nil and viewDidUnload are called.  If you were setting an outlet UIImageView’s image property in your the UIImagePickerDelegate method then nothing was actually being saved.  The Picker would be dismissed and you would have a blank UIImageView.  This is how the first version of this code behaves and closely mirrors many examples on the web.
To fix this you need to store the image sent to the UIImagePickerDelegate in a variable that will not be removed when memory gets low.  That is what is done with the current version of the software.  A UIImage variable is set and then used as the image in the UIImageView.  This now appears to fix the problem and is in the most simple form that I could think of to illustrate the point.  Any pointers are welcome.

The code can be found at


No Comments

Posted in iOS


Tags: , ,