ios – Typing animation not working for second ViewController


The typing animation works on the basis ViewController with this code:

        tremendous.viewDidLoad()
        
        
        welcomeBack.textual content = ""
        var charIndex = 0.0
        let welcomeBackText = "Welcome Again"
        for letter in welcomeBackText {
            Timer.scheduledTimer(withTimeInterval: 0.1 * charIndex, repeats: false) { (timer) in
                self.welcomeBack.textual content?.append(letter)
            }
            charIndex += 1
        } 

Nonetheless, once I enter a brand new ViewController, the identical animation doesn’t occur with the very same code. I attempted altering viewDidLoad to viewDidAppear nevertheless it didn’t work.

Please assist me determine easy methods to get this typing animation to work when a brand new ViewController opens, even when it isn’t the basis ViewController.

That is the code for the second viewController:

        tremendous.viewDidLoad()
        
        
        newAccount.textual content = ""
        var charIndex = 0.0
        let newAccountText = "New Account"
        for letter in newAccountText {
            Timer.scheduledTimer(withTimeInterval: 0.1 * charIndex, repeats: false) { (timer) in
                self.newAccount.textual content?.append(letter)
            }
            charIndex += 1
        }