iOS 9中的Popover演示文稿

时间:2015-10-20 10:07:06

标签: ipad swift2

我想在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)

1 个答案:

答案 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)

希望这有帮助。