【发布时间】:2017-01-20 14:24:20
【问题描述】:
我正在尝试在 iPhone 中显示弹出框。我正在遵循我在此处找到的建议并使用委托“adaptivePresentationStyle”,但从未调用此函数,并且 ViewController 将始终以全屏模式呈现。我有“UIPopoverPresentationControllerDelegate”和以下功能:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let identifier = segue.destination.restorationIdentifier ?? ""
if identifier == "NavigationSetup" {
if let destinationNav = segue.destination as? UINavigationController {
let destination = destinationNav.topViewController as! SetupTableViewController
destination.popoverPresentationController?.delegate = self
destination.popoverPresentationController?.backgroundColor = UIColor.blue
if self.myApp.isIpad{
destination.preferredContentSize = CGSize(width: 600, height: 620)
}else{
destination.preferredContentSize = CGSize(width: 0.8 * self.view.frame.size.width, height: 0.8 * self.view.frame.size.height)
}
self.cellAnimations.fade(image: self.imageBlur, initOpacity: 0, endOpacity: 1, time: 0.3, completion: nil)
destination.setupDismiss = {[weak self] () in
if let weakSelf = self{
weakSelf.cellAnimations.fade(image: weakSelf.imageBlur, initOpacity: 1, endOpacity: 0, time: 0.3, completion: nil)
}
}
}
}
}
func adaptivePresentationStyle(for controller:UIPresentationController) -> UIModalPresentationStyle {
print("adaptive was called")
return .none
}
那么,我在这里缺少什么?
【问题讨论】:
-
我想..你不见了..
popController.modalPresentationStyle = UIModalPresentationStyle.popover -
谢谢伙计,但我使用的是“destination”,应该使用“destinationNav”。它现在可以工作了。