现在我正在iPhone应用程序中工作,使用UIImageView创建一个动画,它工作正常,然后我试图调用一个方法,当动画一旦完成,然后按钮显示在屏幕上,但该按钮显示第一个然后动画开始,我希望一旦动画完成,然后按钮显示在屏幕上,如何解决这个问题?请帮我如何在iPhone中设置UIImageView动画?
由于提前
我试过这个,供大家参考:
- (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];
}
使用的NSTimer在启动动画。 –
朗姆酒您的方法1延迟8秒后 – Rajneesh071