Reputation: 93
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)
}
}
}
}
Upvotes: 1
Views: 233
Reputation: 93
The solution is to reset the progress value to 0
I tried it in viewDidAppear func and it worked!
overide viewDidAppear func (_ animated: Bool) {
super.viewDidAppear(true)
self.progressive.progress = 0
}
Upvotes: 0
Reputation: 1414
Don't forget to reset progressView somewhere:
self.progressive.setProgress(0, animated: false
)
Upvotes: 1