2010-11-25 56 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

相关问题