People, when I click in a button, several (5) animations in diferents parts of the view starts showing.
So, I have the folowing code:
Code:
UIImageView *explosion;
float delay;
for (int i=0; i<5;i++) {
delay = 2.2;
explosion = [[UIImageView alloc] init];
if (i==0) {
[explosion setFrame:CGRectMake( 115.0f, 50.0f, 100.0f, 200.0f)];
}
else if (i==1) {
[explosion setFrame:CGRectMake( 30.0f, 100.0f, 75.0f, 191.0f)];
}
else if (i==2){
[explosion setFrame:CGRectMake( 240.0f, 100.0f, 75.0f, 191.0f)];
}
else if (i==3){
[explosion setFrame:CGRectMake( 0.0f, 109.0f, 240.0f, 300.0f)];
delay = 2.8;
}
else if (i==4) {
[explosion setFrame:CGRectMake( 90.0f, 109.0f, 240.0f, 300.0f)];
delay = 2.8;
}
explosion.animationDuration = delay;
explosion.animationRepeatCount = 1;
explosion.animationImages = [arrayOfArrays objectAtIndex:i];
[self.view addSubview:explosion];
[explosion startAnimating];
[self performSelector: @selector(hideAnimation:)
withObject:explosion
afterDelay:delay];
[explosion release];
}
arrayOfArrays, is an Array, witch have the Array of images of all the animations. So it is an array of arrays (ex.: in the position 1 have an array of all the images of the first animation, in the position 2 the same, but of the second animation).
It works fine on the simulator.
When I tested it on my iPod, it has a delay (like a lag), and when the 5 animation appears, it is alredy by the end..
But when I click on the button again (the
second time), it works fine!
After that, everything runs normally (I can click as many time as I want on the button, that it will show me the 5 animations at the same time normaly, just like on the simulator).
What can I do? What is happening? And why only on the iPod?
Thanks!