10.1 C
London
Thursday, March 28, 2024

ios – Tips on how to dismiss the primary scene in Swift?


I’m creating a cellular software with Swift in xCode (14.5) atmosphere.

There are two completely different scenes named ViewController.swift and XYZViewController.swift within the Predominant (Base) storyboard.

Initially, the ViewController.swift file runs on the display screen. As a result of a SpeechScreen display screen seems right here. Then, redirection is made to the XYZViewController.swift file.
The issue begins right here. Sure, redirection to XYZViewController.swift happens. Nonetheless, the ViewController.swift file nonetheless runs within the background. So, onboardingLottieView, the animation nonetheless runs within the background.
After redirecting to the XYZViewController.swift file, I need to shut the ViewController.swift scene. However the code beneath doesn’t work accurately. The animation nonetheless works within the background.

I took a have a look at the iOS documentation

I additionally reviewed this web page.
Really, it’s a downside just like the one on this web page. Right here it closes the Second View Controller. I’m making an attempt to shut the First view controller.

I attempted navigate XYZViewController from the navigation controller. However I could not obtain this both.

I am not an expert in iOS growth. I am studying some new issues. I might be glad if you happen to assist.

ViewController.swift file as follows:

import UIKit
import Lottie
class ViewController: UIViewController {
    @IBOutlet weak var onboardingLottieView: LottieAnimationView!
    //...
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        self.showSpeechScreen()
    }
    
    func showSpeechScreen() {
        // onboardingLottieView...
        onboardingLottieView.play()
        Timer.scheduledTimer(timeInterval: 3, goal: self, selector: #selector(presentNextViewController), userInfo: nil, repeats: false)
    }
    @objc func presentNextViewController() {
        // Dismiss the present view controller
        self.dismiss(animated: true) {
            // Redirect to XYZViewController
            let storyboard = UIStoryboard(identify: "Predominant", bundle: nil)
            if let vc = storyboard.instantiateViewController(withIdentifier: "XYZViewController") as? XYZViewController {
                vc.modalPresentationStyle = .computerized
                vc.modalTransitionStyle = .crossDissolve
                self.current(vc, animated: true)
            }
        }
    }
}

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here