Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display images of type .jpeg or .gif or .tiff in iphone sdk

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

like image 599
Madan Mohan Avatar asked Nov 06 '22 08:11

Madan Mohan


1 Answers

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.

like image 86
Rushil Avatar answered Nov 09 '22 09:11

Rushil