Erreur sur bouton de présentation UIAlertController

Bonjour à tous,
Je reviens vers vous car j’ai un message d’erreur que je n’arrive pas à résoudre et qui n’intervient que lors ce que je test sur un iPad.

Voici le message :
2018-12-03 13:31:31.102236+0100 Kingdomino Scorer[23588:3106517] *** Terminating app due to uncaught exception ‘NSGenericException’, reason: ‘Your application has presented a UIAlertController (<UIAlertController: 0x7fab7684fa00>) of style UIAlertControllerStyleActionSheet from UINavigationController (<UINavigationController: 0x7fab77001800>). 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.’
*** First throw call stack:
(
0 CoreFoundation 0x00000001049dc1bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000103f7a735 objc_exception_throw + 48
2 UIKitCore 0x0000000113c29ed1 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3168
3 UIKitCore 0x0000000113c3387b __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2495
4 UIKitCore 0x0000000113c30e6b __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 468
5 UIKitCore 0x00000001143410d2 _runAfterCACommitDeferredBlocks + 318
6 UIKitCore 0x000000011432fb2c _cleanUpAfterCAFlushAndRunDeferredBlocks + 384
7 UIKitCore 0x000000011435eefc _afterCACommitHandler + 135
8 CoreFoundation 0x0000000104940c27 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
9 CoreFoundation 0x000000010493b0be __CFRunLoopDoObservers + 430
10 CoreFoundation 0x000000010493b751 __CFRunLoopRun + 1537
11 CoreFoundation 0x000000010493ae11 CFRunLoopRunSpecific + 625
12 GraphicsServices 0x0000000108bba1dd GSEventRunModal + 62
13 UIKitCore 0x000000011433581d UIApplicationMain + 140
14 Kingdomino Scorer 0x00000001036257b7 main + 71
15 libdyld.dylib 0x00000001070d8575 start + 1
16 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Google Traduction :
Terminaison de l’application en raison de l’exception non capturée ‘NSGenericException’, raison: 'Votre application a présenté une feuille UIAlertController (<UIAlertController: 0x7feb198a0e00>) de style UIAlertControllerControllerSuppleActionSheet de UINavigationController (<UINavigationController:) Le modalPresentationStyle d’un UIAlertController avec ce style est UIModalPresentationPopover. Vous devez fournir des informations de localisation pour ce popover via popoverPresentationController du contrôleur d’alerte. Vous devez fournir un sourceView et sourceRect ou un barButtonItem. Si ces informations ne sont pas connues lorsque vous présentez le contrôleur d’alertes, vous pouvez les fournir dans la méthode UIPopoverPresentationControllerDelegate -prepareForPopoverPresentation.

Le soucis vient quand le clic sur le bouton “More Apps” :

func moreAppsABERNARD (presentedViewController : UIViewController!) {
    guard #available(iOS 10.0, *) else {
        returnHome()
        return }
    
        let alertController = UIAlertController(title: "Voir mes applications", message: "Je vous propose de voir mes autres applications sur l'AppStore ou sur mon site internet", preferredStyle: .actionSheet)
    
        alertController.addAction(UIAlertAction(title: "Simple Calc",
                                                style: .default,
                                                handler: { (_ ) in
                                                        UIApplication.shared.open(URL(string: "https://itunes.apple.com/fr/app/simple-calc/id1433983573?l=fr&ls=1&mt=8")! as URL, options: [:], completionHandler: nil)
        }))

    alertController.view.tintColor = #colorLiteral(red: 0.880845964, green: 0.02352941176, blue: 0.07450980392, alpha: 1) //UIColor.red
        alertController.addAction(UIAlertAction(title: "Fermer", style: .cancel, handler: nil))
        present(alertController, animated: true, completion: nil)
    }

func returnHome() -> Void {
    navigationController?.dismiss(animated: true, completion: nil)
}

Salut,

Il ne sait pas ou afficher ton Alert essaye de lui ajouter ça :

alertController.popoverPresentationController?.barButtonItem = self.navigationItem.rightBarButtonItem

ici le rightBarButtonItem correspond à ton More App si il se trouve en haut à droite
Juste avant ton present(…)

Pour fixer ton alert…

++