我有类似下面的方法:如何在UIView动画之后正确释放视图? :)
- (void)add:(id)sender {
MyAddViewController *controller = nil;
controller = [[MyAddViewController alloc] initWithAddType:1];
//controller.delegate = self;
// Do some animation. Slide it in from the right side of the screen.
CGPoint initialCenter = self.view.center;
controller.view.center =
CGPointMake(initialCenter.x + 320, initialCenter.y);
// Add the subview now with it's center + 320 off the screen.
[self.view addSubview:controller.view];
[UIView beginAnimations:@"animation" context:NULL];
[UIView setAnimationDuration:0.35];
[UIView setAnimationDelegate:self];
controller.view.center = CGPointMake(initialCenter.x, initialCenter.y);
//[UIView setAnimationDidStopSelector:@selector(aMethodToBeCalledAfterAnimationEnd:finished:context:)];
[UIView commitAnimations];
//[controller release];
}
你看,我有一个控制器发布在我的add方法的最后一行。如果我取消注释此行,动画将完全死亡,并且只是将视图转储到没有动画的位置。
有没有更好的方式来做到发布,而无需创建另一个经由[UIView的setAnimationDidStopSelect做清理方法:@selector(aMethodToBeCalledAfterAnmiationEnd ...
或者我可以这样做setAnimationDidStopSelector? :@selector([controller release])?:)
在此先感谢!
我试过使用新的基于块的动画,我似乎无法达到所需的效果。基本上我有_currentView_和_incomingView_应该在currentView的顶部滑动。 _incomingView_是一个全视图(320x480或其他),除了它的上半部分是透明的,所以你应该看到旧视图的底部,当它被添加为子视图。它可以与上面的动画代码一起工作,但是我不能用基于块的动画来实现它。基于块的转换似乎也会在转换过程中增加一些愚蠢的淡化效果,而上面没有。 – 2011-03-01 02:48:20