我有以下代码来显示没有箭头的popoverview(对话框),它工作正常.唯一的问题是,对话框显示在左上角(IPad).我想将视图置于屏幕中心.
在我的下面的代码中要更改或添加什么?:
func show_help(){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewControllerWithIdentifier("Help") as! UIViewController
controller.modalPresentationStyle = UIModalPresentationStyle.popover
let popoverPresentationController = controller.popoverPresentationController
// result is an optional (but should not be nil if modalPresentationStyle is popover)
if let _popoverPresentationController = popoverPresentationController {
// set the view from which to pop up
_popoverPresentationController.sourceView = self.view;
_popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.allZeros;
// present (id iPhone it is a modal automatic full screen)
self.presentViewController(controller, animated: true, completion: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
额外的信息
在我的视图中,链接到我的viewcontroller我设置了这样的优先大小:
override …Run Code Online (Sandbox Code Playgroud)