Nikos Nikos - 1 year ago 138
iOS Question

iOS9 popover always points to top-left corner of anchor

I'm using a storyboard segue that presents a view controller as popover. The seque has a custom

as its anchor. On pre-iOS9 the popover would correctly point to the centre-bottom of the custom
(presented below the UIView). On iOS9 it points to the top-left corner of the

I did try to trace all selector calls to the custom
to find out if there is anything I may need to implement in my custom
to provide the 'hotspot' for the popover but couldn't find anything

Any ideas..? Thanks

Thanks to @Igor Camilo his reply - in case it's useful to some, this is how I fixed this in my code:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

UIPopoverPresentationController* possiblePopOver = segue.destinationViewController.popoverPresentationController;
if (possiblePopOver != nil) {
// iOS9 -- ensure correct sourceRect
possiblePopOver.sourceRect = possiblePopOver.sourceView.bounds;

Example: 'Short' button triggers a popover, the popover points to the top-left corner of 'Sort' control

Resulting popover

Segue settings

Answer Source

I had the exact same problem. I just resolved it by setting sourceRect in prepareForSegue:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    switch segue.identifier {
    case "Popover Identifier"?:
        if #available(iOS 9.0, *) {
            segue.destinationViewController?.popoverPresentationController?.sourceRect = anchorView.frame
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download