我想在iPad中的Popover中显示一个viewController。但这一行 self.poc =在iOS 9中删除的UIPopoverController(contentViewController:sec)
let sec:PopView=PopView(nibName:"PopView",bundle:nil)
self.poc = UIPopoverController(contentViewController: sec)
poc!.delegate=self
self.poc!.presentPopoverFromRect( CGRect(x: 150, y: 222, width: 50, height: 30), inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Right, animated: true)
答案 0 :(得分:0)
您需要使用UIPopoverPresentationController:
let sec = UIViewController(nibName:"PopView",bundle:nil)
sec.modalPresentationStyle = .Popover
if let secPopoverPresentationController = sec.popoverPresentationController{
secPopoverPresentationController.sourceView = yourSourceView
secPopoverPresentationController.permittedArrowDirections = [.Any]
//Optionally configure other things like sourceRect , delegate ...
}
presentViewController(sec, animated: true, completion: nil)
希望这有帮助。