In Swift, I am trying to show a popover from a panel button element located in the upper right position of the navigation bar. Below is my code:
func showOptions(sender: UIBarButtonItem) {
let optionsVC = OptionsViewController(nibName: "OptionsViewController", bundle: nil)
optionsVC.delegate = self
optionsVC.modalPresentationStyle = .popover
optionsVC.preferredContentSize = CGSize(width: 200, height: 200)
present(optionsVC, animated: true, completion: nil)
let popController = optionsVC.popoverPresentationController
popController?.permittedArrowDirections = .up
popController?.delegate = self
popController?.barButtonItem = sender
}
func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .none
}
His work is good on the iPad, not on the iPhone. I looked through the documentation and various web pages. Everything seems to be correct. What is missing in my code?
source
share