Kibernetik
Kibernetik

Reputation: 3028

Why popover does not have an arrow on iPhone?

I am displaying a popover on a button press. Popover points its arrow to the button pressed:

UIViewController * controller = [self.storyboard instantiateViewControllerWithIdentifier: @"popover view"];
controller.modalPresentationStyle = UIModalPresentationPopover;
controller.popoverPresentationController.sourceView = button.imageView;

[self presentViewController: controller
                   animated: YES
                 completion: nil];

This is how popover view controller is defined in a storyboard: enter image description here

The problem is that on iPhone this popover is drawn fullscreen, while on iPad and Mac it is drawn with an arrow pointing to the button. I want it to have an arrow always.

I have seen that popovers on iPhone can have arrows, but cannot get it. What am I missing? Why iPhone popover is drawn fullscreen and without an arrow?

Upvotes: 2

Views: 365

Answers (1)

Phil Dukhov
Phil Dukhov

Reputation: 88357

You need to implement adaptivePresentationStyleForPresentationController:traitCollection: of UIPopoverPresentationControllerDelegate and return UIModalPresentationNone for popoverPresentationController delegate

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
                                                               traitCollection:(UITraitCollection *)traitCollection
{
    return UIModalPresentationNone;
}

Upvotes: 4

Related Questions