I am trying to use an Image View to make an animation with a sequence of 60 pictures, but it simply does not work. When I run the application on the IOS simulator, the first image that I have put in the "image" field in the inspetor is shown, but it keeps static (the animation does not run).
I began choosing a View Based Application, then I double-clicked on the ViewController's nib file and, in the Interface Builder, I put a View and an Image View into the view.
In my File's Owner Object I put an UIImageView Outlet, and then I connected that Outlet to the Image View.
There is my viewController's ".h" file:
// AenigmAViewController.h
//
// Created by Fabio Moreira Goncales on 24/02/11.
// Copyright 2011 Particular. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
NSMutableArray *imageArray;
@interface AenigmAViewController : UIViewController {
IBOutlet UIImageView *imageView;
}
@end
There is my viewController's ".m" file:
//
// AenigmAViewController.m
//
// Created by Fabio Moreira Goncales on 24/02/11.
// Copyright 2011 Particular. All rights reserved.
//
#import "AenigmAViewController.h"
@implementation AenigmAViewController
-(void)viewDidLoad {
[super viewDidLoad];
NSMutableArray *imageArray = [[NSMutableArray alloc] init];
for (int i = 0; i < 60; i++){
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat
"4Mindsv00%d.png", i]]];
}
imageView.animationImages = [NSArray arrayWithArray:imageArray];
imageView.animationDuration = 2.00;
imageView.animationRepeatCount = 0;
[self.view addSubview:imageView];
[imageView startAnimating];
NSLog(@"array's content:%@",imageArray);
NSLog(@"animationImages:%@",imageView.animationImages);
NSLog(@"imageView Object:%@",imageView);
NSLog(@"Executed");
}
@end
And there's my Log File result (note that the imageView Object is shown as null):
26/02/11 10:02:22 AenigmA[263] array's content
"<UIImage: 0x4b12cf0>",
"<UIImage: 0x4b127d0>",
"<UIImage: 0x4b170c0>",
"<UIImage: 0x4b17d30>",
"<UIImage: 0x4b197d0>",
"<UIImage: 0x4b1a690>",
"<UIImage: 0x4e0bf90>",
"<UIImage: 0x4e43d80>",
"<UIImage: 0x4e44080>",
"<UIImage: 0x4b1b340>",
"<UIImage: 0x4b1b9f0>",
"<UIImage: 0x4b1d220>",
"<UIImage: 0x4b1cb30>",
"<UIImage: 0x4b1f120>",
"<UIImage: 0x4b1ffe0>",
"<UIImage: 0x4b20ea0>",
"<UIImage: 0x4b21d60>",
"<UIImage: 0x4b21ef0>",
"<UIImage: 0x4b23b50>",
"<UIImage: 0x4b24a10>",
"<UIImage: 0x4b24320>",
"<UIImage: 0x4b268d0>",
"<UIImage: 0x4b27790>",
"<UIImage: 0x4b28650>",
"<UIImage: 0x4b29510>",
"<UIImage: 0x4b2a3d0>",
"<UIImage: 0x4b2b290>",
"<UIImage: 0x4b2c150>",
"<UIImage: 0x4b2d010>",
"<UIImage: 0x4b2c9d0>",
"<UIImage: 0x4b2ede0>",
"<UIImage: 0x4b2fca0>",
"<UIImage: 0x4b30b60>",
"<UIImage: 0x4b24dc0>",
"<UIImage: 0x4b32aa0>",
"<UIImage: 0x4b33960>",
"<UIImage: 0x4b348e0>",
"<UIImage: 0x4b357a0>",
"<UIImage: 0x4b36660>",
"<UIImage: 0x4b37520>",
"<UIImage: 0x4b383e0>",
"<UIImage: 0x4b392a0>",
"<UIImage: 0x4b3a160>",
"<UIImage: 0x4e45a10>",
"<UIImage: 0x4e45f30>",
"<UIImage: 0x4e47760>",
"<UIImage: 0x4e48620>",
"<UIImage: 0x4e494e0>",
"<UIImage: 0x4e4a3a0>",
"<UIImage: 0x4e4b3a0>",
"<UIImage: 0x4e4c260>",
"<UIImage: 0x4e4d120>",
"<UIImage: 0x4e4dfe0>",
"<UIImage: 0x4e4eea0>",
"<UIImage: 0x4e4fd60>",
"<UIImage: 0x4e50c20>",
"<UIImage: 0x4e51ae0>",
"<UIImage: 0x4b31150>",
"<UIImage: 0x4b3b030>",
"<UIImage: 0x4b3c860>"
)
26/02/11 10:02:22 AenigmA[263] animationImages
null)
26/02/11 10:02:22 AenigmA[263] imageView Object
null)
26/02/11 10:02:22 AenigmA[263] Executed
I began choosing a View Based Application, then I double-clicked on the ViewController's nib file and, in the Interface Builder, I put a View and an Image View into the view.
In my File's Owner Object I put an UIImageView Outlet, and then I connected that Outlet to the Image View.
There is my viewController's ".h" file:
// AenigmAViewController.h
//
// Created by Fabio Moreira Goncales on 24/02/11.
// Copyright 2011 Particular. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
NSMutableArray *imageArray;
@interface AenigmAViewController : UIViewController {
IBOutlet UIImageView *imageView;
}
@end
There is my viewController's ".m" file:
//
// AenigmAViewController.m
//
// Created by Fabio Moreira Goncales on 24/02/11.
// Copyright 2011 Particular. All rights reserved.
//
#import "AenigmAViewController.h"
@implementation AenigmAViewController
-(void)viewDidLoad {
[super viewDidLoad];
NSMutableArray *imageArray = [[NSMutableArray alloc] init];
for (int i = 0; i < 60; i++){
[imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat
}
imageView.animationImages = [NSArray arrayWithArray:imageArray];
imageView.animationDuration = 2.00;
imageView.animationRepeatCount = 0;
[self.view addSubview:imageView];
[imageView startAnimating];
NSLog(@"array's content:%@",imageArray);
NSLog(@"animationImages:%@",imageView.animationImages);
NSLog(@"imageView Object:%@",imageView);
NSLog(@"Executed");
}
@end
And there's my Log File result (note that the imageView Object is shown as null):
26/02/11 10:02:22 AenigmA[263] array's content
"<UIImage: 0x4b12cf0>",
"<UIImage: 0x4b127d0>",
"<UIImage: 0x4b170c0>",
"<UIImage: 0x4b17d30>",
"<UIImage: 0x4b197d0>",
"<UIImage: 0x4b1a690>",
"<UIImage: 0x4e0bf90>",
"<UIImage: 0x4e43d80>",
"<UIImage: 0x4e44080>",
"<UIImage: 0x4b1b340>",
"<UIImage: 0x4b1b9f0>",
"<UIImage: 0x4b1d220>",
"<UIImage: 0x4b1cb30>",
"<UIImage: 0x4b1f120>",
"<UIImage: 0x4b1ffe0>",
"<UIImage: 0x4b20ea0>",
"<UIImage: 0x4b21d60>",
"<UIImage: 0x4b21ef0>",
"<UIImage: 0x4b23b50>",
"<UIImage: 0x4b24a10>",
"<UIImage: 0x4b24320>",
"<UIImage: 0x4b268d0>",
"<UIImage: 0x4b27790>",
"<UIImage: 0x4b28650>",
"<UIImage: 0x4b29510>",
"<UIImage: 0x4b2a3d0>",
"<UIImage: 0x4b2b290>",
"<UIImage: 0x4b2c150>",
"<UIImage: 0x4b2d010>",
"<UIImage: 0x4b2c9d0>",
"<UIImage: 0x4b2ede0>",
"<UIImage: 0x4b2fca0>",
"<UIImage: 0x4b30b60>",
"<UIImage: 0x4b24dc0>",
"<UIImage: 0x4b32aa0>",
"<UIImage: 0x4b33960>",
"<UIImage: 0x4b348e0>",
"<UIImage: 0x4b357a0>",
"<UIImage: 0x4b36660>",
"<UIImage: 0x4b37520>",
"<UIImage: 0x4b383e0>",
"<UIImage: 0x4b392a0>",
"<UIImage: 0x4b3a160>",
"<UIImage: 0x4e45a10>",
"<UIImage: 0x4e45f30>",
"<UIImage: 0x4e47760>",
"<UIImage: 0x4e48620>",
"<UIImage: 0x4e494e0>",
"<UIImage: 0x4e4a3a0>",
"<UIImage: 0x4e4b3a0>",
"<UIImage: 0x4e4c260>",
"<UIImage: 0x4e4d120>",
"<UIImage: 0x4e4dfe0>",
"<UIImage: 0x4e4eea0>",
"<UIImage: 0x4e4fd60>",
"<UIImage: 0x4e50c20>",
"<UIImage: 0x4e51ae0>",
"<UIImage: 0x4b31150>",
"<UIImage: 0x4b3b030>",
"<UIImage: 0x4b3c860>"
)
26/02/11 10:02:22 AenigmA[263] animationImages
26/02/11 10:02:22 AenigmA[263] imageView Object
26/02/11 10:02:22 AenigmA[263] Executed