【发布时间】:2011-03-01 01:35:49
【问题描述】:
我有如下方法:
- (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];
}
你看我有一个 controller release 作为我添加方法的最后一行。如果我取消注释此行,动画将完全消失,它只是将视图转储到没有动画的位置。
有没有更好的方法来做 release 而不必创建另一个通过 [UIView setAnimationDidStopSelect:@selector(aMethodToBeCalledAfterAnmiationEnd... 进行清理的方法?
或者我可以做类似 setAnimationDidStopSelector:@selector([controller release]) 的事情吗? :)
提前致谢!
【问题讨论】:
标签: iphone cocoa-touch memory-management ios4