【发布时间】:2010-10-30 18:26:16
【问题描述】:
我正在尝试显示包含 NavigationController 的模态视图控制器。不过,我不知道在哪里释放控制器。通常,我会在显示控制器后将其释放,但这在这里行不通;大概这与导航控制器有关。任何帮助都会很棒!这是有问题的代码:
-(IBAction)displayCreateModifyExerciseViewController:(id)sender {
CreateModifyExerciseViewController *controller = [[CreateModifyExerciseViewController alloc] initWithNibName:@"CreateModifyExerciseView"
bundle:nil];
controller.delegate = self;
controller.title = @"Create Exercise";
UINavigationController *modalNavController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
modalNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Save"
style:UIBarButtonItemStyleDone
target:controller
action:@selector(done:)];
[self presentModalViewController:modalNavController animated:YES];
//I want to say [controller release];
// [modalNavController release];
//But that causes a crash because controller ends up dealloc-ing.
}
【问题讨论】:
标签: iphone memory-management ios