Search code examples
model-view-controllermodalviewcontrollerpushviewcontroller

iOS : How to avoid program quit during the 2nd call viewController?


I've an iPad app that can call the 2nd viewController by pressing a next button. But when I press the next button, it is successfully called the 2nd viewController but when I press return the program quits (Program received signal). Anything wrong with my Xcode4 ?

.m mainController 

-(IBAction) next{

UIViewController * about = [[UIViewController alloc] initWithNibName:@"about" bundle:nil];
[self presentModalViewController:about animated:YES];

[about release];

}

.m 2nd viewController

   - (IBAction)btnReturn {

    [self.view removeFromSuperview];
    [self dismissModalViewControllerAnimated:YES];

}
- (void)dealloc
{
    [UIViewController release];
    [super dealloc];
}

Solution

  • These two lines make no sense, you should remove them:

    1. [self.view removeFromSuperview];
    2. [UIViewController release];

    Line 1: You don't have to remove your view from the superview. Dismissing the modal controller should be sufficient.

    Line 2: If anything, you should release an object, not a class.