To be able to show such ViewController (the orange one) in a popover, you have to define the modalPresentationStyle
as popover
doing so:
class ParentViewController: UIViewController, UIPopoverPresentationControllerDelegate {
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "PopoverSegue" {
let popoverVc = segue.destination
popoverVc.modalPresentationStyle = .popover
popoverVc.popoverPresentationController?.delegate = self;
popoverVc.preferredContentSize = CGSize(width: 250, height: 250)
}
}
}
remember to set the segue identifier (PopoverSegue
or whatever) in the interface builder:

the following freeform size (ignored at runtime), will be important to simulate your popover view inside the interface builder:

final result is:
