4
在Swift中,我试图通过导航栏右上角的酒吧按钮项显示弹出窗口。以下是我的代码:在iPhone的导航栏中显示从酒吧按钮弹出来
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
}
它在ipad上运行良好,而不是在iPhone上。我已经通过文档和不同的网页。一切似乎都是对的。我的代码中缺少什么?
非常感谢。许多博客展示了我实施的方式。 – Satyam