Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

presenting view from popover

In my app a user can press a tableviewcell which shows a popover with a button in it's header. Pressing this button will present a navigation view controller.

DNWInfoViewController *infoViewController = [[DNWInfoViewController alloc] initWithInfoText:infoText];
    UINavigationController *navController    = [[UINavigationController alloc] initWithRootViewController:infoViewController];
    navController.modalPresentationStyle     = UIModalPresentationFormSheet;
    [self presentViewController:navController animated:YES completion:nil];

But since iOS 8 I get this warning and the view doesn't show up:

Warning: Attempt to present <UINavigationController: 0x180e1dc0>  on <ANProjectFilterViewController: 0x16ec5cf0> which is already presenting (null)

This must be because the popovercontroller is still showing so I tried this before presenting the view

[_ppvrController dismissPopoverAnimated:YES]; // This will not call the delegate

This 'fix' works some times. But most of the times it still shows the warning and not my view. I tried manually calling the delegate but that gave the same results.

This used to work great in iOS 7 and lower. How can I present a new view from a popover in iOS 8?

EDIT 1

Show I've found that

dismissPopoverAnimated

doesn't work in iOS 8 for some reason. Normally when a user selects an item from the popover a method is called which first dismisses the popover and then does some custom stuff. In iOS 7 the popover disappears on selection but not in iOS 8.

EDIT 2

So what actually triggers the warning is this piece of code:

[_ppvrController dismissPopoverAnimated:YES];

This piece of code is inside a method. That method is called from a button which is inside the presented popover. Half of the time the popup is succesfully dismissed but sometimes it just prints the warning en the popover stays visible.

Note: there's no other code inside this method. Just that one line to dismiss the popover.

like image 795
Mark Molina Avatar asked Mar 19 '23 08:03

Mark Molina


1 Answers

That seems a bug on iOS 8. I suggest you report it to Apple. In the meantime, I read that other people are using this workaround:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
    [self presentViewController:yourNewNavigationController animated:YES completion:nil];
}];
like image 124
Ricardo Sanchez-Saez Avatar answered Mar 31 '23 20:03

Ricardo Sanchez-Saez