Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimating retina images
    primarykey
    data
    text
    <p>I'm trying to animate some images. The images are working well on non-retina iPads but their retina counterparts are slow and the animations will not cycle through at the specified rate. The code i'm using is below with the method called every 1/25th second. This method appears to perform better than <code>UIViewAnimations</code>.</p> <pre><code>if (counter &lt; 285) { NSString *file = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Animation HD1.2 png sequence/file_HD1.2_%d", counter] ofType:@"png"]; @autoreleasepool { UIImage *someImage = [UIImage imageWithContentsOfFile:file]; falling.image = someImage; } counter ++; } else { NSLog(@"Timer invalidated"); [timer invalidate]; timer = nil; counter = 1; } } </code></pre> <p>I realise there are a lot of images but the performance is the same for animations with less frames. Like i said, the non-retina animations work well. Each image above is about 90KB. Am i doing something wrong or is this simply a limitation of the iPad? To be honest, i find it hard to believe that it couldn't handle something like this when it can handle the likes of complex 3D games so i imagine i'm doing something wrong. Any help would be appreciated.</p> <p><strong>EDIT 1:</strong> </p> <p>From the answers below, I have edited my code but to no avail. Executing the code below results in the device crashing.</p> <p>in <code>viewDidLoad</code></p> <pre><code>NSString *fileName; myArray = [[NSMutableArray alloc] init]; for(int i = 1; i &lt; 285; i++) { fileName = [NSString stringWithFormat:@"Animation HD1.2 png sequence/HD1.2_%d.png", i]; [myArray addObject:[UIImage imageNamed:fileName]]; NSLog(@"Loaded image: %d", i); } falling.userInteractionEnabled = NO; falling.animationImages = humptyArray; falling.animationDuration = 11.3; falling.animationRepeatCount = 1; falling.contentMode = UIViewContentModeCenter; </code></pre> <p>the animation method</p> <pre><code>-(void) triggerAnimation { [falling startAnimating]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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