親愛的,我有一個基於導航的應用程序約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];
}
感謝您的回覆。我爲您的評論添加了一些代碼 – Ian 2010-11-26 02:45:48