I'm trying to create a custom ViewController that will act as a UIAlertViewController, meaning that it will be displayed over the current ViewController, and will be dismissible after the user presses OK. Let's call this the ErrorViewController.
In all the case where I present this ErrorVC it works properly, overlaying the underlying ViewController. However, there is one particular ViewController that gets hidden whenever it presents the ErrorVC.
The code for presenting the ErrorVC is the following:
@objc static func showError(from presentingViewController: UIViewController,
title: String = kErrorSomethingWentWrong,
message: String? = kErrorTryAgainLater,
type: ErrorViewControllerType = .message) -> ErrorViewController {
let errorViewController = UIStoryboard.main.instantiateViewController(withIdentifier: ErrorViewController.identifier) as! ErrorViewController
presentingViewController.modalPresentationStyle = .currentContext
errorViewController.modalPresentationStyle = .overFullScreen
errorViewController.modalTransitionStyle = .crossDissolve
// Set the delegate of the dialog box to the parentViewController
errorViewController.delegate = presentingViewController as? ErrorViewControllerDelegate
errorViewController.errorTitle = title
errorViewController.errorMessage = message ?? kErrorTryAgainLater
errorViewController.type = type
// Present the pop up viewController from the parentViewController
presentingViewController.present(errorViewController, animated: true)
return errorViewController
}
I've tried setting definesPrersentationContext to true on my problematic ViewController with no luck. When debugging the view hierarchy, I can see that the problematic ViewController is removed from the hierarchy, and that's why it's not visible, while on all other ViewControllers the presentingViewController stays in the view hierarchy.
Any ideas on what could be causing this issue?