Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make sure that UIImageView's setImage has completed before the next frame
    text
    copied!<p>I have some code that continuously generates UIImage frames for animation. Currently I am using a mutable array to save these image objects which can be animated using UIImageView animation methods. Something like following:</p> <pre><code>NSMutableArray *myFrames...; while ( number of frames required ) { create UIImage frame_xx; [myFrames addObject:frame_xx]; } myUImageView.animationImages = myFrames; myUImageView.animationDuration = time_length_for_animation; [myUImageView startAnimating]; </code></pre> <p>The above code works fine, however my problem is that as my animation gets longer then few hundred frames, I start getting memory warnings and eventually the program crashes.</p> <p>What I would ideally like to do is to display each frame immediately rather then generating a bunch of frames for animation. Animation may be a bit slower this way but I will not be limited to the memory. As soon as the frame_xx is displayed I no longer care for that frame and want to display the next frame.</p> <p>I have tried using following and they don't work:</p> <pre><code>[myUImageView setImage:frame_xx] // This only displays the last frame generated in the loop </code></pre> <p>I have also tried creating a new thread:</p> <pre><code> [NSThread detachNewThreadSelector: @selector(displayImage) toTarget:myUImageView withObject:frame_xx]; // again this only shows the last frame generated in the loop </code></pre> <p>So I am looking for help.. how do you display an image frame immediately in UIImageView, sort of like "flush" right after [myUImageView setImage:frame_xxx]</p> <p>Any help on this will be greatly appreciated..</p> <p>KAS</p>
 

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