I'm using a storyboard segue that presents a view controller as popover. The seque has a custom UIView
as its anchor. On pre-iOS9 the popover would correctly point to the centre-bottom of the custom UIView
(presented below the UIView). On iOS9 it points to the top-left corner of the UIView
.
I did try to trace all selector calls to the custom UIView
to find out if there is anything I may need to implement in my custom UIView
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
A bit of a more updated answer for Swift 3! Pardon all the casting
just to update to an actual example with working code for any UIView
Had the same issue but my app has a multitude of pop-over so I created a centralized function for the fix (but still had to use it on every view controller that had pop overs).