UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs - crash

Viewed 12

When I am trying to use the share function, I am receving the error

 UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs.

Code that is causing the issue is below, in particular the final line;

func displayActivityViewController() {
   
    
    let activityItems = [getOutPutUrl()] as [Any]
    let activityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
    let mainDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate
    mainDelegate.window?.rootViewController?.present(activityViewController, animated: true, completion: nil)

}
0 Answers
Related