Search code examples
iosxcodeswift5progressuiprogressview

Why UIProgressView set progress not stopping?


I want to show pregress bar animation before to move to the App or Auth VC

By below code it worked fine but the problem it worked for one time only ( the time you start the Application )

So, the question is it stopping issue ? and if it is how to handle it pls??

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(true)


        Auth.auth().addStateDidChangeListener { (auth, user) in
        if user == nil {
            // User Signed out

            self.progressive.setProgress(3, animated: true)
            // Before calling asyncAfter perform showing loader or anything you want.


            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
                // Your code to execute after a delay of 3 seconds.
                self.performSegue(withIdentifier: "Auth", sender: nil)
            }

        } else {
            // User Signed In

            self.progressive.setProgress(3, animated: true)
            // Before calling asyncAfter perform showing loader or anything you want.

            self.progressive.setProgress(3, animated: true)

            DispatchQueue.main.asyncAfter(deadline: .now() + 3) {

                self.performSegue(withIdentifier: "App", sender: nil)
            }
        }
    }
}

Solution

  • Don't forget to reset progressView somewhere:

    self.progressive.setProgress(0, animated: false)