Tag: popover uipopover

UIPopoverPresentationController以全屏显示popup窗口

我正在尝试使用UIPopoverPresentationController来显示不占用整个屏幕的popover窗口。 我跟着很多不同的教程,没有运气。 这是我的代码。 它正确地实例化ViewController ,但它占用了整个屏幕,而不是像我在preferredContentSize定义的那样只是一个较小的屏幕。 func showPopover() { let vc = self.storyboard?.instantiateViewControllerWithIdentifier("PopupTimePickerViewController") as PopupTimePickerViewController vc.modalPresentationStyle = .Popover vc.preferredContentSize = CGSizeMake(200, 100) if let presentationController = vc.popoverPresentationController { presentationController.delegate = self presentationController.permittedArrowDirections = .Up presentationController.sourceView = self.view presentationController.sourceRect = CGRectMake(0, 0, 50, 50) self.presentViewController(vc, animated: true, completion: nil) } } 更新9/27/16正确的答案 func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: […]