I'm attempting to display a small modal popover using the new UIPopoverPresentationController
, and while it's more or less working, the popover bubble that it is contained in is being cut off in a very weird way:
Looks like there is a piece missing from the bottom, but I can't figure out why.
Here is the code I am using to present the popover (note that the sourceView is on an inputAccessoryView):
UIViewController *popoverVC = [self.storyboard instantiateViewControllerWithIdentifier:@"profilePopover"];
popoverVC.preferredContentSize = CGSizeMake(300,120);
popoverVC.modalPresentationStyle = UIModalPresentationPopover;
self.profilePopoverController = popoverVC.popoverPresentationController;
self.profilePopoverController.delegate = self;
self.profilePopoverController.sourceView = self.chatBar.profilePictureButton;
self.profilePopoverController.sourceRect = self.chatBar.profilePictureButton.bounds;
self.profilePopoverController.permittedArrowDirections = UIPopoverArrowDirectionDown;
popoverVC.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:popoverVC animated:YES completion:nil];
I've just run into this issue when presenting my own popover from a segue, and every time I thought I fixed it, it cropped up again.
I think I've finally got it though. It seems to be related to the values in the destination controller's
preferredContentSize
and the popover controller'ssourceRect
. The content size was the one that I had to adjust the most.If the size values aren't integral (so it needs to be 2.0 not 2.5 for example) or if they aren't even (so it can be 2.0 but not 1.0), this would happen. I've included my prepare for segue method where I set everything up. I wanted my popover size to be relational to the total size of my view, but this should apply to more than just that scenario. My button size (for the
sourceRect
) is fixed so my measurements happen to work without needing similar adjustment, but I'm guessing the same limitations apply here as well.I can't say for sure that these are the only triggers for this issue, but it did end up fixing it for me on all iPhone screen sizes.