animation一个圆圈成长

我用UIImageViewanimation一个圆圈的图像,生长和淡入重复:

-(void)animateOuterCircle { NSLog(@"animating circles"); [UIView animateWithDuration:1.5 delay:.5 options:(UIViewAnimationOptionAllowUserInteraction) animations:^{ self.outerCircle.transform=CGAffineTransformMakeScale(.25, .25); } completion:nil]; [UIView animateWithDuration:1.5 delay:.5 options:(UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction) animations:^{ self.outerCircle.transform=CGAffineTransformMakeScale(1.5, 1.5); self.outerCircle.alpha = 0; } completion:nil]; [self.view bringSubviewToFront:self.outerCircle]; } 

我在viewDidAppear中调用这个方法:

 - (void)viewDidAppear:(BOOL)animated { [self performSelectorOnMainThread:@selector(animateOuterCircle) withObject:nil waitUntilDone:NO]; //other code } 

它将animation罚款时,我加载mainView。 问题是我加载view2和closuresview2,当我回到主视图,它不是animation了。

任何想法为什么发生这种情况?

编辑:方法被称为:

 2012-03-15 14:11:13.946[1529:17903] view2 canceled //dismissing view2 2012-03-15 14:11:13.947[1529:17903] mapView viewWillAppear fired 2012-03-15 14:11:13.948[1529:17903] mapView viewWillAppear end 2012-03-15 14:11:14.352[1529:17903] mapView viewDidAppear fired 2012-03-15 14:11:14.353[1529:17903] animating circles 2012-03-15 14:11:14.354[1529:17903] mapView viewDidAppear end 

编辑2:

 -(IBAction) fourthBtn:(id)sender { view2 *view2 = [self.storyboard instantiateViewControllerWithIdentifier:@"view2"]; [self presentModalViewController:view2 animated:YES]; } 

解雇视图2:

 -(IBAction) cancel:(id) sender { NSLog(@"heir canceled"); [self dismissModalViewControllerAnimated:YES]; } 

另外,我不会在我的代码中随时停止animation。

我的猜测是viewDidAppear没有被调用,因为从这个angular度来看,它永远不会消失。

根据你如何创build和显示view2,当你closures它的时候这会在view2中工作吗?

 [parentViewController viewDidAppear:YES]; 

我重新做了一些代码;

 -(void)viewWillDisappear:(BOOL)animated { [self.outerCircle removeFromSuperview]; [self.innerCircle removeFromSuperview]; } - (void)viewDidAppear:(BOOL)animated { self.innerCircle = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"inner-circle.png"]]; self.innerCircle.frame = CGRectMake(self.innerCircle.frame.origin.x, self.innerCircle.frame.origin.y, 30, 30); self.outerCircle = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"outer-circle.png"]]; self.outerCircle.frame = CGRectMake(self.outerCircle.frame.origin.x, self.outerCircle.frame.origin.y, 40, 40); [self.view insertSubview:self.innerCircle belowSubview:HUD]; [self.view insertSubview:self.outerCircle belowSubview:HUD]; //other code } 

随着这些变化,它的行为也是我想要的。

我认为这与尝试再次对外圈进行animation处理有关(它已经从第一个viewDidAppear开始animation,而当viewDidAppear被第二次调用时,它重新激活了一个已经有animation的图像,并且完全将其完成)。