我有这个功能,
-(void)transitionstar{
star.hidden = NO;
star2.hidden = NO;
star3.hidden = NO;
star4.hidden = NO;
star5.hidden = NO;
star6.hidden = NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4f];
[UIView animateWithDuration:0.0 animations:^{
CGAffineTransform scale = CGAffineTransformMakeScale(1, 1);
CGAffineTransform rotate = CGAffineTransformMakeRotation(360.0);
CGAffineTransform rotate2 = CGAffineTransformMakeRotation(-360.0);
CGAffineTransform rotate3 = CGAffineTransformMakeRotation(-720.0);
CGAffineTransform rotate4 = CGAffineTransformMakeRotation(720.0);
CGAffineTransform rotate5 = CGAffineTransformMakeRotation(1080.0);
CGAffineTransform rotate6 = CGAffineTransformMakeRotation(-1080.0);
CGAffineTransform translate = CGAffineTransformMakeTranslation(-800, -800);
CGAffineTransform translate2 = CGAffineTransformMakeTranslation(600, -600);
CGAffineTransform translate3 = CGAffineTransformMakeTranslation(400, 400);
CGAffineTransform translate4 = CGAffineTransformMakeTranslation(-200, 200);
CGAffineTransform translate5 = CGAffineTransformMakeTranslation(900, -300);
CGAffineTransform translate6 = CGAffineTransformMakeTranslation(-200, 500);
CGAffineTransform transform = CGAffineTransformConcat(translate, scale);
transform = CGAffineTransformConcat(transform, rotate);
CGAffineTransform transform2 = CGAffineTransformConcat(translate2, scale);
transform2 = CGAffineTransformConcat(transform2, rotate2);
CGAffineTransform transform3 = CGAffineTransformConcat(translate3, scale);
transform3 = CGAffineTransformConcat(transform3, rotate3);
CGAffineTransform transform4 = CGAffineTransformConcat(translate4, scale);
transform4 = CGAffineTransformConcat(transform4, rotate4);
CGAffineTransform transform5 = CGAffineTransformConcat(translate5, scale);
transform5 = CGAffineTransformConcat(transform5, rotate5);
CGAffineTransform transform6 = CGAffineTransformConcat(translate6, scale);
transform6 = CGAffineTransformConcat(transform6, rotate6);
star.transform = transform;
star2.transform = transform2;
star3.transform = transform3;
star4.transform = transform4;
star5.transform = transform5;
star6.transform = transform6;
}
completion:^(BOOL finished){
if (finished) {
star.hidden = YES;
star2.hidden = YES;
star3.hidden = YES;
star4.hidden = YES;
star5.hidden = YES;
star6.hidden = YES;
}
}];
[UIView commitAnimations];
}
当我第一次调用它时,它确实有效。
但是,我在同一视图内再次调用,它无法执行并卡在那里。
-隐藏的工作
- 过渡不起作用
- 旋转不起作用
-nslog 工作
为什么第二次会变成这样?
更新
if(!positionrepeat)
{
//Display Correct IMAGE;
[isrepeat addObject:[NSNumber numberWithInt:positionvalue]];
//soundeffect = [self createSoundID: @"correct"];
//AudioServicesPlaySystemSound(soundeffect);
[self displayresulttext:@"correct"];
[self.view setNeedsDisplay];
[self transitionstar];
correct++;
completed.text = [NSString stringWithFormat:@"%d", correct];
[self result];
}
这就是我调用函数的方式。然而,还是一样。