Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange warning dismissing modal view controller

I'm working on iOS 6. My application has a standard navigation controller with embedded a CustomViewController. In this controller I create a modal view like this:

-(IBAction)presentModalList:(id)sender {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    StationsListViewController *list = [storyboard instantiateViewControllerWithIdentifier:@"StationsListViewController"];
    [list setStationsData: [self.stationsData allValues]];
    [self presentModalViewController:list animated:YES];
}

The modal controller show perfectly but dismissing generates a warning. The dismiss method in this controller is:

-(IBAction)backToMap
{
    [self dismissModalViewControllerAnimated:YES];
}

The warning generated is Warning:

Attempt to dismiss from view controller < UINavigationController: 0x1ed91620 > while a presentation or dismiss is in progress!

Any clues about that?

Thanks

like image 623
Sparviero Avatar asked Sep 04 '12 09:09

Sparviero


Video Answer


2 Answers

I realise this is a late answer but maybe this will help someone else looking for a solution to this, here is what I did:

-(IBAction)backToMap
{
    if (![[self modalViewController] isBeingDismissed])
        [self dismissModalViewControllerAnimated:YES];
}

For me, i found that line of code was being called multiple times, I couldn't find out why so this was the easiest fix.

like image 153
JDx Avatar answered Sep 18 '22 17:09

JDx


Thanks JDx for getting me on the right track. I adapted it to form this solution, which will remove the warning without using functions that are deprecated in iOS 6:

-(IBAction)backToMap
{
    if (![self.presentedViewController isBeingDismissed]) {
        [self dismissViewControllerAnimated:YES completion:^{}];
    }
}
like image 24
Kyle Clegg Avatar answered Sep 16 '22 17:09

Kyle Clegg