,當我通過解僱ModalViewController我的應用程序崩潰:請協助modalViewController崩潰
[self.parentViewController dismissModalViewControllerAnimated:YES];
這種模式視圖 - 控制器(「MVC」)提出,當用戶點擊一個UINavigationController的細胞之一(「NavRoot」) - 這裏是對於該代碼:
MVC *modalView = [[MVC alloc] initWithNibName:@"MVC" bundle:nil];
[self.navigationController presentModalViewController: modalView animated:YES];
[modalView release];
其被加載的「modalView」只包含2個對象:一個UIWebView對象和「完成」按鈕,這點擊的何時的dissmissing通過:
[self.parentViewController dismissModalViewControllerAnimated:YES];
除了當我點擊「完成」 - 應用程序崩潰。
當我使用NSZombies運行儀器時,我發現保留計數達到-1,但我無法確定是什麼原因導致了這種過度釋放。
我發現的唯一的事情解決了問題是,要麼添加了「[modalView保留]」聲明「NavRoot」 - 這是對的viewController做modalView的呈現:
MVC *modalView = [[MVC alloc] initWithNibName:@"MVC" bundle:nil];
[self.navigationController presentModalViewController: modalView animated:YES];
[modalView retain]; // <<== new 'retain' statement
[modalView release];
或者只是簡單地從來沒有釋放modalView擺在首位:
MVC *modalView = [[MVC alloc] initWithNibName:@"MVC" bundle:nil];
[self.navigationController presentModalViewController: modalView animated:YES];
// commenting out the 'release':
// [modalView release];
這兩個選項扔國旗當我運行「分析」(「上線34分配的對象的潛在泄漏」 ......),但他們這樣做解決問題。 不過,我擔心這會導致應用程序被Apple從App Store拒絕。
關於可能導致過度釋放的任何想法?或者我可能會進一步嘗試隔離/識別問題?
連接儀器的圖像/殭屍報告:
你可以顯示殭屍儀器的歷史嗎? –
好吧,我會放棄它 - 現在運行,但一定會發布它,因爲我絕對需要到這個底部! – sirab333
你的MVC dealloc是什麼樣的? MVC是否充當webview的委託,如果是的話,你是否在dealloc中進行清理? –