【发布时间】:2015-07-23 11:27:57
【问题描述】:
我只是想在现有的主 UIViewController/UIView 上显示一个小选项对话框,这样在 iPad 上我会看到一个小对话框,而在后台我会看到主视图。
我设法以模态视图样式显示 UIViewController/UIView,如下所示:
func showoptions(){
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewControllerWithIdentifier("Options") 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.sourceRect = CGRectMake(60, 100, 500, 500)
//_popoverPresentationController. .setPopoverContentSize(CGSizeMake(550, 600), animated: true)
//_popoverPresentationController.sourceView.sizeToFit();
// present (id iPhone it is a modal automatic full screen)
self.presentViewController(controller, animated: true, completion: nil)
}
}
但我还有一些问题: 1.如何去掉边界处的箭头。 2. 如何调整这个模态视图的大小。它显示得很小,我想将它安装到 UIControllerView/UIView 中最大的控件中。
有什么帮助吗?
【问题讨论】:
标签: swift uiview uiviewcontroller modal-dialog