Hi , I am fairly new as you will be able to tell in about a few characters.
I am trying to do a simple image animation with an array containing my images.
The code runs. but the app in the iphone tester closes itself(crashes?) after less than a second without any error hint.
I am declaring the nsarray and uiimageview like this:
.h
.m
Now i figured out that the error is in the line
But I had a bit of a look around and the code looks fine. The locList NSArray seems to somehwo cause trouble, so I know I am fairly close, but just cant get it to work.
anyone?
I am trying to do a simple image animation with an array containing my images.
The code runs. but the app in the iphone tester closes itself(crashes?) after less than a second without any error hint.
I am declaring the nsarray and uiimageview like this:
.h
Code:
@class NSArray;
@interface NSTimerDemoViewController : UIViewController
{
int animationFrame;
UIImageView *imageView;
NSArray *locList;
UIImage *newImage;
NSTimer *myTimer;
CLLocationManager *locationManager;
}
@property (nonatomic, retain) IBOutlet UIImageView *imageView;
@property (nonatomic, retain) IBOutlet NSArray *locList;
@property (nonatomic, retain) IBOutlet UIImage *newImage;
@end
.m
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
locList = [NSArray arrayWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"], nil];
imageView.image = [UIImage imageNamed:@"2.png"];
//imageView.animationImages = locList;
//imageView.animationDuration = 3;
//imageView.animationRepeatCount = 0;
//[imageView startAnimating];
[self.view addSubview:imageView];
animationFrame = 0;
myTimer = [NSTimer scheduledTimerWithTimeInterval:1/4 target:self selector:@selector(timeHandler) userInfo:nil repeats:YES];
}
-(void)timeHandler
{
animationFrame = animationFrame + 1;
if(animationFrame>=3){
animationFrame = 0;
}
NSLog (@"show stuff %d",animationFrame);
imageView.image = [locList objectAtIndex: animationFrame];
}
Now i figured out that the error is in the line
Code:
imageView.image = [locList objectAtIndex: animationFrame];
But I had a bit of a look around and the code looks fine. The locList NSArray seems to somehwo cause trouble, so I know I am fairly close, but just cant get it to work.
anyone?