views:

57

answers:

1

Hi Guys,

I am facing a problem while displaying the image in iphone. I used the below code but it work only for .png files.

      UIImageView* imageView=[[UIImageView alloc] initWithFrame:CGRectMake(6,10, 80, 80)];
      imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:customerListObject.customerImage]]];
      [myView addSubview:imageView];
      [imageView release];

I could not display the other types of image file, Please suggest me the solution.

Thank you, Madan Mohan

A: 

Try using this:

imageView.image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"imagename" ofType:@"png"]];

And then replace imagename and png with your file name and type.

Rushil
I am getting the image url from parser, how can i use NSBundle
Madan Mohan