Anjaneyulu Anjaneyulu - 1 year ago 128
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]]]]];

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 Source

Download the Files from here.....

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download