ios – How to move from one view controller to another with the new completely replacing the old?


I am new to iOS development and I am using swift and storyboard. The app is able to move between two view controllers using button actions but I need to move between view controllers when an image is pressed

@objc func imageTapped(backArrowListener:UITapGestureRecognizer)
    {
        print("Button tapped")
        
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "MainScreenController") as! MainScreenController
        self.navigationController?.pushViewController(vc, animated: true)
        self.present(vc, animated: true, completion: nil)

I am using the above code which results in the new view being displayed on top of the old one instead of replacing it. I am looking for the same result as an iOS storyboard segue or android intent

I have tried altering the code but it does not give the desired effect, any help with this would be appreciated

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img