-1

When the login process is of type Post using Alamofire

I want to show the sign in progress while waiting for the server

....

For example, such as the view above the login screen appears when you press the login button and disappear when you enter the home screen

This solution did not work :::



        func show () {
            let alert = UIAlertController(title: nil, message: "Please wait...", preferredStyle: .alert)

            let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
            loadingIndicator.hidesWhenStopped = true
            loadingIndicator.style = UIActivityIndicatorView.Style.gray
            loadingIndicator.startAnimating();

            alert.view.addSubview(loadingIndicator)
            vc.present(alert, animated: true, completion: nil)
           // vc.dismiss(animated: false, completion: nil)

        }

iyas seyam
  • 55
  • 1
  • 9
  • check this link https://www.hackingwithswift.com/example-code/uikit/how-to-use-uiactivityindicatorview-to-show-a-spinner-when-work-is-happening – Mirzohid Akbarov Aug 09 '19 at 21:01
  • 1
    UIAlertController is a pretty closed system. Its designed to be the system standard alert. You should not be adding subviews to it. I would create an custom UIViewController that can act as an alert. You can use the custom UIViewController transition to make appear the same way UIAlertController does. There are also many GitHub projects that provide custom alert styles that you might like. Such as this one: https://github.com/DominikButz/DYAlertController from https://stackoverflow.com/a/43002878/2677861 – Mirzohid Akbarov Aug 09 '19 at 21:04

1 Answers1

-1

If you want to use CocoaPods, use https://cocoapods.org/pods/SVProgressHUD

To use it, call SVProgressHUD.show() right before sending the http request, and then call SVProgressHUD.dismiss() once the login is successful.

Hope it helps.

Cheers.

  • I want to ask you about the countdown timer library https://github.com/suzuki-0000/CountdownLabel – iyas seyam Aug 09 '19 at 22:15
  • I have implemented the instructions in their website but when I put it in the label.text it doesn't work can you help me ? – iyas seyam Aug 09 '19 at 22:16