UITableViewController를 모달 뷰로 포함하는 UINavigationController를 제시 할 때 메모리 관리에 문제가 있습니다. 나는 UINavigationController와 UITableViewController를 모두 autorelease하지만, Allocations Instrument를 사용하는 동안 모달 뷰를 열고 닫으면 뷰가 생성하는 메모리가 해제되지 않습니다.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];
}
감사합니다.