Dismiss Popover using Unwind Segue in Xcode Storyboard

Posted by AlexR on Stack Overflow See other posts from Stack Overflow or by AlexR
Published on 2012-11-19T15:48:37Z Indexed on 2012/11/20 17:00 UTC
Read the original article Hit count: 555

I am using Xcode 4.5 and the new iOS 6 feature to unwind segues. I am presenting a navigation view controller inside a popover which is presented programmatically from a bar button item:

- (IBAction)configChartTapped:(id)sender
{
    if (self.popover.isPopoverVisible) {

        [self.popover dismissPopoverAnimated:YES];

    } else {
        UINavigationController *chartConfigNavigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"GrowthChartNavigationController"];

        ConfigChartTypeViewController *configChartTypeViewController = (ConfigChartTypeViewController*) chartConfigNavigationController.topViewController;

        self.popover = [[UIPopoverController alloc]initWithContentViewController:chartConfigNavigationController];
        self.popover.popoverContentSize = CGSizeMake(320, 500);
        self.popover.delegate = self;

        [self.popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}

Next to this method I have defined a target to unwind the segue (i.e. dismissing the popover)...

- (IBAction)cancelConfig:(UIStoryboardSegue *)segue
{
    //
}

... and connected it to a cancel button in the navigation view controllers's navigation bar.

Connecting the cancel bar button to the cancelConfig button worked fine in Xcode.

However, when running the code, nothing happens when clicking on the Cancel button despite Xcode 4.5 should be supporting dismissing popovers when unwinding segues (according to the release docs).

What did I miss?

Thank you!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about ios