I would like to present a PopOverPresentationVC from a ContainerVC (loaded from Storyboard). My code below : -
@IBAction func showPopOverVC(view: UIView){
let embeddedVC: EmbeddedVC = instantantiateVC() // my personal helper method
embeddedVC.popoverPresentationController?.sourceView = view
embeddeVC.modalPresentationStyle = .popover
present(embeddedVC, animated: true)
}
I keep on getting this error UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs. , though I am setting the sourceView correctly. Any suggestions is much appreciated.
Funnily enough if I remove the line : -
embeddeVC.modalPresentationStyle = .popover
The modal presentation works fine.
So the answer is you need to set tht popover presentation properties in this order, if you reverse, the app would crash, crazy I say :)