Anjaneyulu Anjaneyulu - 6 months ago 14
iOS Question

Faster way to load an image from a URL and display it in an iPhone app

I am using the following code to display an image in my ImageView:

imgbackBG.image = [UIImage imageWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [test.arrImagessplash objectAtIndex:[test.arrImages count]-4]]]]];

4cing.com/mobile_app/uploads/pageicon/splash.png


The problem is that the code executes very slowly. Is there a way to load the image and display it in the ImageView more quickly? If so, how can I do this?

Answer

Download the Files from here.....

https://github.com/nicklockwood/AsyncImageView

and use as the following way:

AsyncImageView *asyncImageView = [[AsyncImageView alloc]initWithFrame:CGRectMake(30,32,100, 100)];   
[asyncImageView loadImageFromURL:[NSURL URLWithString:your url]];
[YourImageView addSubview:asyncImageView];
[asyncImageView release];
Comments