I am working with an old app with auto-layout turned off and I just ran into a spot where I need to display a popover on the iPhone.
The code I'm using is the routine:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "popoverSegue" {
let popoverViewController = segue.destinationViewController as! UIViewController
popoverViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
popoverViewController.popoverPresentationController!.delegate = self
}
}
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
Example result with auto-layout on:
Example result with auto-layout off:
Is there a way to show a popover using Apple's built in system without auto-layout?
I believe that the final answer is that you cannot use Apple's built in popover system on the iPhone if you turn off auto-layout.
I strongly suggest writing your own basic UIView display system that handles showing/hiding a view appropriately.
Tip: The most convenient part of the built-in popover system is that it disables the background, points to a relevant item and dismisses on outside tap, etc.
If you can live without the pointing everything else is easy to replicate because you have auto-layout turned off. You can lock the view size to "iPhone" then make the UIView background color clear and full size and drop a smaller "content" view of the appropriate size on top of it. The transparent View disables taps on items under it and you can apply a tap gesture to handle dismissal if needed.