如何在动画执行时等待(how to wait while animation is performing)
我有两个图像视图,称为动画和指令动画图像视图用于播放动画和指令图像视图用于显示指令
我希望在我的动画完成后这样做,然后我想要更改指令图像视图的图像
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if(event.subtype == UIEventSubtypeMotionShake) { NSMutableArray *array = [[NSMutableArray alloc] init]; for(int i=1;i<=20;i++){ [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vivacious%d.png",i] ] ]; } self.animation.animationImages = array; self.animation.animationRepeatCount = 1;//0 for infinite loop self.animation.animationDuration = 1.5; [self.animation startAnimating]; //[NSThread sleepForTimeInterval:1.5]; self.instruction.image = [UIImage imageNamed:@"ah.png"]; } }i have two image view, called animation and instruction animation image view for play animation and instruction image view for display instruction
i want to do that when my animation is finished then i want change the image of instruction image view
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if(event.subtype == UIEventSubtypeMotionShake) { NSMutableArray *array = [[NSMutableArray alloc] init]; for(int i=1;i<=20;i++){ [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vivacious%d.png",i] ] ]; } self.animation.animationImages = array; self.animation.animationRepeatCount = 1;//0 for infinite loop self.animation.animationDuration = 1.5; [self.animation startAnimating]; //[NSThread sleepForTimeInterval:1.5]; self.instruction.image = [UIImage imageNamed:@"ah.png"]; } }最满意答案
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if(event.subtype == UIEventSubtypeMotionShake) { NSMutableArray *array = [[NSMutableArray alloc] init]; for(int i=1;i<=20;i++){ [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vivacious%d.png",i] ] ]; } self.animation.animationImages = array; self.animation.animationRepeatCount = 1;//0 for infinite loop self.animation.animationDuration = 1.5; [self.animation startAnimating]; self.instruction.hidden = YES; [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(changeInstruction) userInfo:nil repeats:NO]; } } -(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ if(event.subtype == UIEventSubtypeMotionShake) { NSMutableArray *array = [[NSMutableArray alloc] init]; for(int i=1;i<=20;i++){ [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vivacious%d.png",i] ] ]; } self.animation.animationImages = array; self.animation.animationRepeatCount = 1;//0 for infinite loop self.animation.animationDuration = 1.5; [self.animation startAnimating]; self.instruction.hidden = YES; [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(changeInstruction) userInfo:nil repeats:NO]; } }更多推荐
发布评论