ios - Cache UIImage using uitableview from url -


With a custom cell containing two UImages, a uitableview hava Images of logo are taken from the online website, so images need to be cached. The image is still loading so far:

  ns URL * imageURL = [ns url URLWithString: [arra1 objectAtIndex: indexPath.row / 2]]; NSDTA * ImageData = [NSDTATA DATAVITY content of the: imageURL]; NS URL * imageURL2 = [NSUr URL YouthString: [Array2 ObjectAntindex: IndexPath.ro / 2]]; NSDTa * ImageData2 = [NSData Datatyh content of the ur image image2]; Cell.ima1.image = [UIImage imageWithData: imageData]; Cell.ima2.image2 = [UIImage imageWithData: imageData2];   

What I learned from searching is that dataWithContentsOfURL does not have asynchronous, and scrolling will take a lot of time. I tried many ways but I can not seem to have the right one. This is my first UIImazing caching for the first time, I appreciate the detailed explanation with the implementation so that I can learn differently from getting a job. Thank you very much

I use this library which is just right

    < Li>

    You can add #import & lt; SDWebImage / UIImageView + WebCache.h & gt; , and you can also define the placeholder when the image is downloaded just this code:

      - (UITableViewCell *) Table view: (UITableView *) Table view CellForOutInpath: (NSIndexPath *) Index Path {Fixed NSString * MyIdentifier = @ "MyIdentifier"; UITableViewCell * cell = [TablesView decomputer reusable cell identifier: MyDenTIFIER]; If (cell == blue) {cell = [[[UITWebWeblog ALLOC] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: MyIdentifier] autorelease]; } // Here we use the new provided image of URL: the method to load the web image [cell.imageView setImageWithURL: [NSURL URLWithString: @ "http://www.domain.com/path/ To / image.jpg "] placeholder image: [UIImage imageNamed: @" placeholder page "]]; Cell.textLabel.text = @ "My Text"; Return cell; }   

    It also cache downloaded images and gives you a very good performance.

    Hope this will help you!

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -