Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do you load images from local files by any chance?</p> <p>By using Instruments I've found that there is some lazy loading mechanism in <code>UIImage</code> - the real image data was decompressed from PNG only at the stage of rendering it on the main thread which caused the lag during scrolling.</p> <p>So, after the loading of <code>UIImage</code> with <code>-initWithContentsOfFile:</code> method, I've added code to render the contents of this image to offscreen context, saved that context as new <code>UIImage</code> and used it for <code>UIImageView</code> in <code>UITableViewCell</code>, this made the scroll to be smooth and pleasant to the eye again. </p> <p>In case of reference there is the simple code I'm using to force reading of image contents in separate thread (using ARC):</p> <pre><code>UIImage *productImage = [[UIImage alloc] initWithContentsOfFile:path]; CGSize imageSize = productImage.size; UIGraphicsBeginImageContext(imageSize); [productImage drawInRect:CGRectMake(0, 0, imageSize.width, imageSize.height)]; productImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre> <p>And I think the surface of <code>UIImage</code> created in such a way will be in the supported format suited for rendering, which will also offload work needed to render it on main thread.</p> <p>EDIT: The docs for <code>UIGraphicsGetImageFromCurrentImageContext()</code> say that it should be only used from main thread, but searching on the net or SO shows that starting from iOS 4 the <code>UIGraphics..</code> methods became thread safe. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload