看看我下面的代碼,我點擊「後退」按鈕後出現內存錯誤,如果我刪除,問題將被修復[aboutView release] 爲什麼?以及我應該如何發佈關於視圖?UIViewController動畫內存版本
-(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];
}
第二個視圖Contorller:
-(IBAction)back {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:1.0];
[self.view setAlpha:0];
[UIView commitAnimations];
[self.view removeFromSuperview];
}
是否有一個原因,你添加'aboutView.view'而不是'aboutView'本身?崩潰的原因是'aboutView'不被保留。 – 2012-04-11 05:20:15