0
Boas, I am trying to implement an Indicator loading in my application with a small message, so that the user can see that information is being processed (in this case fetching the API through Alamofire), but after using this method:
        let alert = UIAlertController(title: nil, message: "A carregar...", preferredStyle: .alert)
        alert.view.tintColor = UIColor.black
        let loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50)) as UIActivityIndicatorView
        loadingIndicator.hidesWhenStopped = true
        loadingIndicator.style = UIActivityIndicatorView.Style.gray
        loadingIndicator.startAnimating();
        alert.view.addSubview(loadingIndicator)
        present(alert, animated: true, completion: nil)
        AF.request(request).responseDecodable { (response: DataResponse<ModeloDados>) in
            loadingIndicator.stopAnimating()
            alert.dismiss(animated: true, completion: nil)
            switch response.result{
             case .success(_):
                if(response.response?.statusCode == 200){
                    self.performSegue(withIdentifier: "segueProcurar", sender: self)
                }
             case .failure(_):
                print("failure")
            }
            print("code: \(response.response?.statusCode)")
        }
I can only use once, since after passing to the second viewcontroller, trying to use again gives the following error:
pushViewController:Animated: called on while an existing Transition or Presentation is occurring; the navigation stack will not be updated.
Someone can help me?
Thank you in advance for any reply.
I think I’m already doing Dismiss with "Alert.Dismiss(Animated: true, Completion: nil)"
– Rui Alves