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

I am having a problem displaying an image on iphone. I used the code below, but it only works 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 other types of image files, please offer me a solution.

Thanks Madan Mohan

+4
source share
1 answer

Try using this:

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

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

+1
source

All Articles