0
當呈現包含UITableViewController作爲模式視圖的UINavigationController時,內存管理出現問題。我autorelease UINavigationController和UITableViewController,但是當我使用分配工具打開然後關閉模式視圖時,視圖創建的內存在關閉時不會釋放。UINavigationController在模式下顯示時不釋放內存
- (void)showOptions {
OptionsViewController *optionsViewController = [[[OptionsViewController alloc] initWithNibName:@"OptionsViewController" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:optionsViewController] autorelease];
navController.navigationBar.tintColor = [UIColor lightGrayColor];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
navController.modalPresentationStyle = UIModalPresentationFormSheet;
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissOptions) name:@"dismissOptions" object:nil];
[[(ApplicationDelegate *)[[UIApplication sharedApplication] delegate] viewController] presentModalViewController:navController animated:YES];
}
- (void)dismissOptions {
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"dismissOptions" object:nil];
[[(ApplicationDelegate *)[[UIApplication sharedApplication] delegate] viewController] dismissModalViewControllerAnimated:YES];
}
謝謝你的時間。