I'm presenting a UISheetPresentationController as the following when a user taps on a gear icon.

@IBAction func settings(_ sender: Any) {
    
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier: "SettingsViewController")
    
    if let presentationController = viewController.presentationController as? UISheetPresentationController {
   
        presentationController.detents = [.medium(),.large()]
     
        self.present(viewController, animated: true)
        
    }
}//settings

However I'm also checking to ensure the Notifications are enabled / disabled. If Notifications has been disabled, I popup and UIAlertController when the app enters the foreground in sceneDidBecomeActive

However if the SettingsViewController was visible on the screen after the app becomes active, I get the following error:

Attempt to present <UIAlertController: 0x145008200> on <UINavigationController: 0x14301a200> (from <xxx.ViewController: 0x14280d8a0>) which is already presenting <xxx.SettingsViewController: 0x142d17460>.

How can I dismiss the UISheetPresentationController when the app becomes sceneWillResignActive or sceneDidEnterBackground

0

There are 0 best solutions below