iPhone UIImage initWithData fails

Posted by DD on Stack Overflow See other posts from Stack Overflow or by DD
Published on 2010-04-21T18:30:56Z Indexed on 2010/04/21 18:33 UTC
Read the original article Hit count: 364

Filed under:
|
|

Hello all,

I'm trying to code up an async image downloader. I use NSURLConnection to get the data into an NSMutableData and use that data once it is complete to initialize a UIImage.

I checked the bytes and it downloads the entire image correctly (right number of bytes at least), however; when I call

[UIImage imageWithData:data]

and then check the properties of the image, it is zero width and a garbage number for height, in fact, same number no matter what the image is. I tried with bunch of different images, png, jpg, different urls, it always downloads the image completely but UIImage can't initialize with that data. What could I be doing wrong here?

Thanks.

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about iphone