I am having a strange issue with UIImagePickerController which is really bugging me. I’ve also found someone else with the same problem so I know it’s not just me!

When using UIImagePickerController, and the imagePickerController:didFinishPickingImage:editingInfo: delegate method gets called, I find that sometimes the returned image is nil, which depending on what you do with the image will cause a crash or at least not do what you expected. It seems to be a memory issue because when you reboot the iPhone and try again, it works and returns the image correctly. Also, I’ve not have the problem on iPhone 3G S which has more RAM, indicating again to a memory issue.

I’m wondering it the new imagePickerController:didFinishPickingMediaWithInfo: delegate method will work – as the other has been deprecated in 3.0 anyway.

But has anyone else had, and fixed, this problem?

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Twitter

7 Responses to “UIImagePickerController returning nil image”

  1. Toby Compton says:

    I am too experiencing this problem, and I am using the new delegate method. The strange thing is that most of the time it works just fine, just occasionally (Not even after selecting an image multiple times) it returns a nil image.

    I am using the original image, and resizing my self as I didn’t like the crop from image picker. I am releasing the picker correctly.

    Did you ever find a solution to this?

    Thanks

  2. Hi Toby,

    I never did find out a solution to the problem, but I’m fairly sure it’s RAM related. I never get it on an iPhone 3GS but it happens all the time on an iPhone 3G. The fix on the 3G is to turn it off and back on, which clears the RAM obviously, so I guess it has to be a RAM issue (and that makes sense anyway).

    Not sure if there is a work-around but I really should file a bug with Apple one day. There’s been far too many devs which have come across the problem now!

  3. gamerpig says:

    I’m also running into the same issue on iPhone 3G. If I reboot the phone, it works. The funny thing is that UIImagePickerController always returns a good image when getting photo from album. However, if the source is camera, I get a nil image until I reboot the phone.

  4. admin says:

    Yes, this issue is because the memory becomes full. You’ll probably be seeing memory warnings being sent to your objects. You can detect this and handle it properly, but unfortunately there’s not really much that you can do to stop it returning nil, except for releasing some memory from your app such that there is enough available for the image picker to return properly.

    If I ever get round to debugging it more then I will post an update.

  5. CharlieUK1977 says:

    Im getting the exact same problem too. Using the new “media” method and again if I switch off the iPhone and switch it back on it always works…

    …on one site it was recommended you create a singleton within the app delegate for the uiimagepicker, but cant seem to get that to work either :-/

  6. andrewprocter says:

    Hi, I’m having the same issue (using both “didFinishPickingImage” and “didFinishPickingMediaWithInfo”. Has anyone solved this yet? I can’t seem to get anywhere with it, but people are downloading an app of mine and complaining that it happens right away. Some sort of global memory problem?

  7. @andrewprocter – One way I heard to do it was to force a memory warning by allocating lots of things which then forces background apps (Mail, Safari, etc) to close which will then leave enough memory for the image picker.

    The other thing… we could all submit bug reports!

Leave a Reply