How Can I set UIBarButtonItem as anchor of a popover in IOS?
In iOS 8 & 9, the presentPopoverFromBarButtonItem:permittedArrowDirections:animated:
method is deprecated. You'll want to set the barButtonItem
property on the view controller's popoverPresentationController
property.
let popover = UIViewController()
popover.modalPresentationStyle = .Popover
if let presentation = popover.popoverPresentationController {
presentation.barButtonItem = navigationItem.rightBarButtonItem
}
presentViewController(popover, animated: true, completion: nil)
You need to use presentPopoverFromBarButtonItem:permittedArrowDirections:animated:
.