2010-11-25 54 views
0

親愛的,我有一個基於導航的應用程序約60意見。iPhone應用程序崩潰,由於低內存,但在模擬器中工作正常

我用以下方式運行: 1.構建和分析:bulid成功,沒有抱怨。 2.儀器分配和泄漏:無泄漏。

但是,該應用程序在iPhone或iPad墜毀,但在模擬器中工作正常。 崩潰發生在大約第50個視圖。 沒有崩潰報告,但我在crashreporter文件夾中看到LowMemory.log。

我已經升級我的iPhone和iPad,以4.2

任何人都不會有想法可能是錯了嗎? 我一直在閱讀和排解故障一週。

謝謝你所有的答覆。

我的應用程序有一個名爲contentViewController的根視圖,用戶可以從這裏導航到4個測驗。

這是我用來返回到我的根視圖的代碼。

- (void)goHome { 
UIAlertView *alert = [[UIAlertView alloc] 
         initWithTitle: @"Warning" 
         message: @"Proceed?" 
         delegate: self 
         cancelButtonTitle:@"Yes" 
         otherButtonTitles:@"No",nil]; 
[alert show]; 
[alert release]; 

}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { 
[[self navigationController] setNavigationBarHidden:NO animated:YES]; 
if (buttonIndex == 0) { 
    NSArray * subviews = [self.view subviews]; 
    [subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 
    self.view = nil; 
    if (self.contentViewController == nil) 
    { 
     ContentViewController *aViewController = [[ContentViewController alloc] 
                initWithNibName:@"ContentViewController" bundle:[NSBundle mainBundle]]; 
     self.contentViewController = aViewController; 
     [aViewController release]; 
    } 
    [self.navigationController pushViewController:self.contentViewController animated:YES]; 
} 

}推意見

示例代碼:

-(IBAction) buttonArrowClicked:(id)sender { 
NSURL *tapSound = [[NSBundle mainBundle] URLForResource: @"click" 
              withExtension: @"aif"]; 

// Store the URL as a CFURLRef instance 
self.soundFileURLRef = (CFURLRef) [tapSound retain]; 

// Create a system sound object representing the sound file. 
AudioServicesCreateSystemSoundID (

            soundFileURLRef, 
            &soundFileObject 
           ); 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 

if (![[defaults stringForKey:@"sound"] isEqualToString:@"NO"]) { 
    AudioServicesPlaySystemSound (soundFileObject); 
}  

if (self.exercise2ViewController == nil) 
{ 
    Exercise2ViewController *aViewController = [[Exercise2ViewController alloc] 
               initWithNibName:@"Exercise2ViewController" bundle:[NSBundle mainBundle]]; 
    self.exercise2ViewController = aViewController; 
    [aViewController release]; 
} 
[self.navigationController pushViewController:self.exercise2ViewController animated:YES]; 

}

回答

3

下運行時,您通常不會遇到內存問題SIMUL ator,所以在這個平臺上不會自動遇到這些錯誤。

然而,模擬器有一個功能,您可以手動觸發低內存事件。如果這實際上是設備崩潰的原因,那麼也可能以這種方式觸發模擬器中的相同錯誤。

0

分享一些關於如何推送視圖控制器的代碼將允許其他人幫助你做到這一點。

可以彈到這樣做更容易根視圖控制器:

[self.navigationController popToRootViewControllerAnimated:YES]; 

你實際上是推你的根視圖控制器的新實例中,您已經共享的代碼。

+0

感謝您的回覆。我爲您的評論添加了一些代碼 – Ian 2010-11-26 02:45:48

相關問題