I've an iOS app with a WKWebview and when I click on a link with an alert popup the app crash, redirecting to AppDelegate with message:
Your application has presented a UIAlertController (<UIAlertController: 0x7f916a840a00>) of style UIAlertControllerStyleActionSheet from Kronos_Sport.ViewController (<Kronos_Sport.ViewController: 0x7f9168808c00>). The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.
I'm not sure what should I add to my ViewController to fix this issue
EDIT: I've added that in viewDidLoad but it still crashes
self.popoverPresentationController?.delegate = self
self.popoverPresentationController?.sourceView = self.view
self.popoverPresentationController?.sourceRect = self.view.bounds
self.popoverPresentationController?.permittedArrowDirections = []