IPhone Popover with AutoLayout disabled
I'm working with an old app with auto layout disabled and I just ran into where I need to display a popover on an iPhone.
The code I'm using is a subroutine:
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
}
An example of an auto-layout result:
Result of the result with automatic layout:
Is there a way to show a popover using Apple's built-in system without auto-layout?
source to share
I believe the definitive answer is that you cannot use Apple's built-in popover system on the iPhone if you turn off auto-layout.
I highly recommend writing your own basic UIView display system that handles showing / hiding the view appropriately.
Council. The most convenient part of the built-in popover system is that it turns off the background, points to the appropriate element and tilts away from an external tap, etc.
If you can live without stating that everything else is easy to replicate, because you turned off auto-linking. You can lock the view size down to "iPhone" and then make the background color of the UIView clear and full, and resize the "content" to an appropriate size on top of it. In transparent view, taps are turned off for items underneath, and you can apply a selection gesture to adjust firing as needed.
source to share
If you are using IOS 8 and above you can try this (Objective-C :().
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
UIViewController *popoverViewController = segue.destinationViewController;
popoverViewController.modalPresentationStyle = UIModalPresentationPopover;
popoverViewController.popoverPresentationController.delegate = self;
}
source to share