我試圖在iPhone中顯示彈出窗口。我遵循我在這裏找到的建議,並使用委託「adaptivePresentationStyle」,但從未調用此函數,並始終以全屏模式呈現ViewController。我有「UIPopoverPresentationControllerDelegate」和功能波紋管:Swift 3 - adaptivePresentationStyle永遠不會調用
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' – TonyMkenu
檢查這個.. http://stackoverflow.com/questions/39972979/popover-in-swift -3-on-iphone-ios/39975346#39975346 – TonyMkenu
謝謝你,但我使用的是「目的地」,應該使用「destinationNav」。現在正在工作。 – ClaytonAV