UIPopoverController modal issue
-
01-06-2021 - |
Question
I have UIPopoverController
UINavigationController *navVC = [[[UINavigationController alloc] initWithRootViewController:loginVC] autorelease];
navVC.modalInPopover = YES;
navVC.modalPresentationStyle = UIModalPresentationCurrentContext;
_popoverLoginVC = [[UIPopoverController alloc] initWithContentViewController:navVC];
And when I present popover
[self.popoverLoginVC presentPopoverFromRect:centerFrame
inView:self.splitVC.view
permittedArrowDirections:0
animated:YES];
It looks like it is modal (I can't close popover by tapping outside) but other area hadn't dimmed. I have played with modalPresentationStyle with no luck (
Please, advise
Solution
Remove the line
navVC.modalInPopover = YES;
navVC.modalPresentationStyle = UIModalPresentationCurrentContext;
OTHER TIPS
It's modal because you're setting it to be modal.
navVC.modalInPopover = YES;
Just delete that and you should be fine if I understand you correctly.
A popover isn't meant to (and can't be specified to) dim the 'background' views, even if presented modally.
permittedArrowDirections:0
This is not a valid value for this parameter and will result in undefined behavior (at least in iOS >= 6). You must specify one of:
UIPopoverArrowDirectionUp = 1UL << 0,
UIPopoverArrowDirectionDown = 1UL << 1,
UIPopoverArrowDirectionLeft = 1UL << 2,
UIPopoverArrowDirectionRight = 1UL << 3,
UIPopoverArrowDirectionAny = UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown | UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight,
Unfortunately, "no arrow" is not a supported option. :(