views:

14

answers:

2

Hi,

I have declared an UIImageView as an IBOutlet and I am setting the image of the imageView as follows in viewDidLoad method

imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
    [NSURL URLWithString: [productProperties objectForKey:@"image"]]]]; 

But this image doesn't show up at all.

productProperties is a NSDictionary which stores the url for the key "image"

I even tried storing the image locally and then setting it up like below

imageView.image = [UIImage imageNamed:@"icons_browse.png"];

But that also doesn't work.

A: 

Try removing the line of code and setting the "default" image in IB.

I know this is not a fix - but I am curious to see of there is some other reason why it is not visible - like it's set as hidden, has 0% alpha, is obscured by something else, etc.

The code - especially the second thing you tried (assuming the file is actually in your bundle and named properly) is very boilerplate and should work..

The other thing to do is to check the value being returned by [UIImage imageNamed] - and make sure it's not nil - meaning there is actually some problem loading the file. (Wrong file name, file not in bundle, etc.)

Brad
Thanks Brad, both the piece of code works
Yogesh
A: 

Sorry guys, it is my mistake, I am providing the wrong value for the NSURL. got it fixed

Yogesh