0

I'm creating a app on a iOS device and it will have a animation on the background but basically i would like to no how many images you can upload to one animation heres the code i have set up.

.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
    IBOutlet UIImageView *animation;
}

@end

.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

-(void)viewDidLoad {



    animation.animationImages = [NSArray arrayWithObjects:

                                 [UIImage imageNamed:@"animatedbg1.gif"],

                                 [UIImage imageNamed:@"animatedbg2.gif"],

                                 [UIImage imageNamed:@"animatedbg3.gif"],

                                 [UIImage imageNamed:@"animatedbg4.gif"],

                                 [UIImage imageNamed:@"animatedbg5.gif"],

                                 [UIImage imageNamed:@"animatedbg6.gif"],

                                 [UIImage imageNamed:@"animatedbg7.gif"],

                                 [UIImage imageNamed:@"animatedbg8.gif"],

                                 [UIImage imageNamed:@"animatedbg9.gif"],nil],





    [animation setAnimationRepeatCount:0];

    animation.animationDuration = 2;

    [animation startAnimating];



} 

At the moment I have 9 images but for my animation I will have 155 images so will that still work :) If not do you guys know a better route I could take?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Picm
  • 89
  • 1
  • 3
  • 10

1 Answers1

0

I don't think there's any firm limit that you'll encounter. However, you may run into memory limits if you use too many images. How large is each image uncompressed? That greatly affects this.

Of course, you probably know that there's no guaranteed amount of memory available for 3rd-party iOS apps. Depending on what else is running on the system, how many web pages the user has open in Mobile Safari, etc., different amounts of free memory will be available.

You may need to build it and experiment.

Just a point of reference. I had an app that was using animationImages, and the images were not quite full-screen (480 x 270 pixels). The images were 24-bit PNGs about 70KB each, compressed.

I found that I could only safely use about 10 of them, and not have to worry too much about getting shut down to handle low memory conditions. Now, at the time, I was targeting iPhone 3G, which is now getting to be quite old. But, you may still want to support iPhone 3G models.

You can certainly query the device model in your code, and set different defaults for how many images your app tries to load. If you want something more generic, that doesn't break when new iOS devices are released, you can ask the device about how much memory it has. Then, you could code your app to only load the even-numbered images if you detect you're running on a device with less memory.

You can also implement didReceiveMemoryWarning in your UIViewControllers, and choose to unload some of the images when you get memory warnings. This all assumes your animation is such that removing images simply makes the animation less smooth-looking, and doesn't make it non-functional altogether.

Here is some information on interpreting iOS memory warnings

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207