【发布时间】:2012-04-11 00:40:46
【问题描述】:
看看我下面的代码,点击“返回”按钮后出现内存错误,如果我删除[aboutView release],问题将得到解决 这是为什么?以及我应该如何发布 aboutView?
-(IBAction)swichView {
AboutView *aboutView = [[AboutView alloc] init];
[aboutView.view setAlpha:0];
[self.view addSubview:aboutView.view];
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:1.0];
[aboutView.view setAlpha:1];
[UIView commitAnimations];
[aboutView release];
}
第二视图控制器:
-(IBAction)back {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:1.0];
[self.view setAlpha:0];
[UIView commitAnimations];
[self.view removeFromSuperview];
}
【问题讨论】:
-
你添加
aboutView.view而不是aboutView本身有什么原因吗?崩溃的原因是aboutView没有被保留。