I'm creating a popover using popoverPresentationController
in Swift. It displays fine for the first time but when I rotate the device it changes its source position.
How can I make it stick at its original source point irrespective of the orientation?
The code that i did.
@IBAction func btn_popover_click(sender: UIButton) {
let menuViewController = PopoverViewController()
menuViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
menuViewController.preferredContentSize = CGSizeMake(50, 100) // Size of popover.
popoverMenuViewController = menuViewController.popoverPresentationController
popoverMenuViewController?.permittedArrowDirections = .Any
popoverMenuViewController?.delegate = self
popoverMenuViewController?.sourceView = sender.superview
popoverMenuViewController?.sourceRect = sender.frame
presentViewController(
menuViewController,
animated: true,
completion: nil)
}