Reputation: 9484
I wanted to segue to a popover in iOS 10, this piece of code used to work fine on iPhone but not now (it shows full screen), what have I done wrong? The segue is set to "Present As Popover".
override func prepare(for segue:UIStoryboardSegue, sender:AnyObject!) {
if segue.identifier == "about" {
let aboutController = segue.destination as! AboutController
aboutController.preferredContentSize = CGSize(width:300, height:440)
let popoverController = aboutController.popoverPresentationController
if popoverController != nil {
popoverController!.delegate = self
popoverController!.backgroundColor = UIColor.black
}
}
}
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
Upvotes: 3
Views: 1839
Reputation: 115061
Many function have been renamed in Swift 3, including adaptivePresentationStyleForPresentationController
- this is now adaptivePresentationStyle(for:)
Change your code to
func adaptivePresentationStyle(for controller:UIPresentationController) -> UIModalPresentationStyle {
return .none
}
Since your function name didn't match it wasn't being called and because it is an optional function in the protocol, you didn't get a warning.
Upvotes: 8
Reputation: 4040
Popover is an iPad only feature. UIKit is smart enough to figure out it should present it modally on iPhone/iPod.
Upvotes: -4