0

I have this separate viewcontroller with identifier MoodController

enter image description here

Now I am using this code to pop it over as a popover

let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let controller = storyboard.instantiateViewController(withIdentifier: "MoodController")
        controller.modalPresentationStyle = UIModalPresentationStyle.popover
        controller.popoverPresentationController!.delegate = self
        self.present(controller, animated: true, completion: nil)

But I am getting this error

2018-04-01 19:19:58.558208+0100 PlanTheDay[14910:215426] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController () should have a non-nil sourceView or barButtonItem set before the presentation occurs.'

what is wrong with my code?

Alex
  • 105
  • 1
  • 5
  • Have you seen this post? Might be helpful: https://stackoverflow.com/questions/25644054/uiactivityviewcontroller-crashing-on-ios-8-ipads – Bram Apr 26 '18 at 12:26
  • Possible duplicate of [UIActivityViewController crashing on iOS 8 iPads](https://stackoverflow.com/questions/25644054/uiactivityviewcontroller-crashing-on-ios-8-ipads) – Bram Nov 21 '18 at 08:13

0 Answers0