I wrote this code so that the viewcontroller changes from loginscreenviewcontroller to otpviewcontroller.
function createAlert() {
let alertController = UIAlertController(title: nil, message: "Please wait\n\n", preferredStyle: .alert)
let spinnerIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
spinnerIndicator.center = CGPoint(x: 135.0, y: 65.5)
spinnerIndicator.color = UIColor.black
spinnerIndicator.startAnimating()
self.present(alertController, animated: true, completion: nil)
Alamofire.request(".....").responseData { response in
switch response.result {
case .success:
self.dismiss(animated: true, completion: nil)
self.performSegue(withIdentifier: "OTPSegue", sender: self)
}
}
}
but it gives me an error
Attempt to present <Junkart.OTPViewController: 0x79769c80> on <UIAlertController: 0x79b5fe00> whose view is not in the window hierarchy!
alert controller does close but there is no change in view controller.
Please help.
UPADTE 2 Ok. So I am able to change to the other viewController but the alert view goes to the top before the new view controller animates and takes the whole screen.