Search code examples
iosuinavigationcontrollermodalviewcontroller

how to dismissModalViewControllerAnimated: YES


I read a lot of documentation about this before i decided to ask. So I have navigationController in my app. When user enters the first time in my app I do this

RegViewController *opr = [[RegViewController alloc] init];
self.regController = opr;
[self.navigationController presentModalViewController:self.regController animated:NO];
[opr release];

And it works fine. But when I click OK button in RegViewController I call this method

-(IBAction)btn_regPressed:(id)sender
{
   NSLog(@"start to dissmis modal");
 [self.navigationController dismissModalViewControllerAnimated:YES];
//[self.navigationController.parentViewController dismissModalViewControllerAnimated:YES];
 }

But this code doesn't want to dismissModalViewController Can somebody help me with thios issue please. Thanks


Solution

  • In your RegViewController, try to dismiss self like so:

    -(IBAction)btn_regPressed:(id)sender
    {
       NSLog(@"start to dissmis modal");
       [self dismissModalViewControllerAnimated:YES];
    }