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)
}
}
}
}
Don't forget to reset progressView somewhere:
self.progressive.setProgress(0, animated: false
)
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.