iPhone using Camera causes array to be unloaded
I have an array of images that I'm displaying in a UITableView. When choosing images from the library using the UIImagePicker, everything is totally fine and I can add a lot开发者_运维技巧 of images to the array. As soon as I add an image from the camera using the Picker I receive a memory warning and my array of images is ditched. Coming back from the camera picker, the table view is empty.
The UIImagePicker when using the camera as the source generates a memory warning before I have a chance to resize the image.
Use Instruments(built into xcode) to watch your memory. I know there are some issues with the ImagePicker and leaks if not released correctly. You should also catch when your app complains about memory.
Are you releasing your array of images in viewDidUnload? Or setting it to nil with the setter?
If so, what could be happening is that your view is not visible when the memory warning occurs (because the UIImagePicker is the top view). The OS calls didReceiveMemoryWarning on your view controller, which by default unloads your view if the view is not visible. Unloading your view calls viewDidUnload.
精彩评论