Now i am working in iPhone application, Using UIImageView to create a animation and it’s working fine, then i tried to call one method for when the animation once completed then the button to show on the screen, but that button showing first then the animation starts, i want once animation completed then the button showing on the screen, how to fix this issue? please help me
Thanks in Advance
I tried this for your reference:
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray * imageArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"cardopen.png"],
[UIImage imageNamed:@"middlecard.png"],
[UIImage imageNamed:@"thirdcard.png"],
[UIImage imageNamed:@"a.png"],
[UIImage imageNamed:@"cardopen1.png"],
[UIImage imageNamed:@"middlecard2.png"],
[UIImage imageNamed:@"thirdcard1.png"],
[UIImage imageNamed:@"2.png"],
nil];
UIImageView * cardsImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 400, 300)];
cardsImage.animationImages = imageArray;
cardsImage.animationDuration = 8.0;
cardsImage.animationRepeatCount=1; // one time looping only
[self.view addSubview:cardsImage];
[cardsImage startAnimating];
[self method1]; // To Call a method1 to show UIButton (Once the animation is completed, then to call a method1)
}
-(void)method1
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame=CGRectMake(10, 40, 50, 50);
[self.view addSubview:btn];
}
(Why doesn’t anybody understand the concept of asynchronous methods? Is this that hard?)
returns immediately, not after the animation finished. You have to set an explicit timeout: