Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning window hierarchy when loading delegate

Today I update my Xcode and started updating my app for the new iPhone 5 screen.

I suddenly notice that every time I go from Screen A to Screen B I get this warning:

Warning: Attempt to present on whose view is not in the window hierarchy!

// This delegate method prepares the segue from Screen A (DilemmaViewController) to Screen B (OptionsViewController)
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Executes the following "if" statement if the user wants to add new options
    if ([segue.identifier isEqualToString:@"AddOptions"]) 
    {
        UINavigationController *navigationController = segue.destinationViewController;
        OptionsViewController *controller = (OptionsViewController *)navigationController.topViewController;
        controller.delegate = self;

        // If the user has already put some inputs on the form we send them through the segue
        if ([edit count] > 0){            
            controller.edit = edit;
        }            
    }
}

I haven't touched this since the first version of my app so I'm not sure of what can be happening here.

I've looked around the web and some people talk about moving code from viewDidLoad to viewAppear but I don't think that applies to this scenario.

like image 411
Juan González Avatar asked Nov 11 '12 13:11

Juan González


1 Answers

Well I figured it out.

My problem was that at some point I made the mistake of connecting the Touch Up Inside event on top of the original (and correct) segue event:

enter image description here

Now that I fixed it:

enter image description here

It's working correctly again.

like image 138
Juan González Avatar answered Sep 30 '22 20:09

Juan González