2012-05-22 55 views
0

我是iPhone SDK的新手,導航控制器上出現泄漏。 這裏是我的代碼:導航控制器上的內存管理

- (空)SignupClicked:(ID)發送 {

if(appdelegate.isiPad){ 
    SignUpViewController *obj_SignUpViewController =[[SignUpViewController alloc] initWithNibName:@"SignUpViewControllerIpad" bundle:nil]; 
    [self.navigationController pushViewController:obj_SignUpViewController animated:YES]; 
    [obj_SignUpViewController release]; 
} 
else { 
    SignUpViewController *obj_SignUpViewController =[[SignUpViewController alloc] initWithNibName:@"SignUpViewController" bundle:nil]; 
    [self.navigationController pushViewController:obj_SignUpViewController animated:YES]; 
    [obj_SignUpViewController release]; 
} 

}

我在這些線路上越來越泄漏:

[self.navigationController pushViewController:obj_SignUpViewController animated:YES]; 
[self.navigationController pushViewController:obj_SignUpViewController animated:YES]; 

請幫我... 謝謝...

+0

此代碼是很好..嘗試清除和分析再次 –

回答

2

將視圖控制器推到導航控制器上時,它將被保留。因此,您需要立即釋放它,否則您將會泄漏。

[obj_SignUpViewController release]; 
+0

邇,示例代碼執行釋放'obj_SignUpViewController'。 – theory

+0

是的,他補充說,看到迴應 –

+0

哦。這很煩人。 – theory

相關問題