我正在动画化的UIImageView与增长和衰落一个圆,重复的图像:动画一圈成长
-(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
}
它将动画很好,当我加载mainView。问题是我加载view2并关闭view2,当我回到mainView,它不再是动画。
任何想法为什么会发生这种情况?
编辑:方法被称为:
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];
}
另外,我不停止自己的动画在我的代码中的任何一点。
也许'viewDidAppear'没有被调用?显示视图切换代码。 – 2012-03-15 17:49:48
viewDidAppear甚至被称为?你自己加载view2时是否停止动画? – Brodie 2012-03-15 17:50:53
viewDidAppear确实被调用,animateOuterCircle确实被调用。 – Padin215 2012-03-15 19:12:32