0
我想在UIPopoverPresentationController(如iOS設置應用程序)中顯示viewController,當我們選擇語言時。它在設備屏幕的中心呈現一個viewController! iPad上的UIPopoverPresentationController
但是,我的結果不是那樣的!
這是我的代碼:
func rightButtonPressed(rightBarButton: UIBarButtonItem) {
let detailVC = self.storyboard?.instantiateViewControllerWithIdentifier("ExampleViewController") as! ExampleViewController
detailVC.modalPresentationStyle = .Popover
let popOverVC = detailVC.popoverPresentationController
popOverVC?.permittedArrowDirections = .Any
popOverVC?.barButtonItem = rightBarButton
popOverVC?.sourceView = self.view
popOverVC?.delegate = self
self.presentViewController(detailVC, animated: true, completion: nil)
}
和委託:
extension DetailViewController: UIPopoverPresentationControllerDelegate {
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
debugPrint(controller.description)
return .Popover
}
func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? {
let navController = UINavigationController.init(rootViewController: controller.presentedViewController)
return navController
}
}
顯示代碼如何目前公關是否存在 –
@JoeBenton我加了我的代碼:)) –