现在我在 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];
}