I’m currently having an issue with UIViewController‘s presentModalViewController:animated:.
I use the following code to set up and show the modal view controller:
UINavigationController *navigationController = [[UINavigationController alloc] init];
AddSerialController *serialController = [[AddSerialController alloc] initWithNibName:@"AddSerial" bundle:nil];
[navigationController pushViewController:serialController animated:NO];
[self.parentViewController presentModalViewController:navigationController animated:YES];
[serialController release];
[navigationController release];
The Application (running in iPhone Simulator) crashes as soon as dismissModalViewControllerAnimated: is called. GDB says it crashes at objc_msgSend.
If I comment out the last line of code (release of the navigation controller) everything works but I’m leaking a UINavigationController (as expected).
What the hell is going on here?
When you create a UINavigationController, you should give it a root view controller: