Disable multiple view controllers showing the wrong view during a transition

I have a total of 4 UIViewControllers. Each of the views has a button that, when clicked, represents the next view manager. When the button on the last UIViewController is pressed, the rejectViewControllerAnimated (true, completion: nil) function is called on the root controller. When called, it immediately renders View # 2, instead of staying with View # 4 when it transitions back to View # 1. The documentation says that when you do this, the topmost view is the only view that will be animated during dismissal, but is that not the case for me? This also happens if I used segues.

class ViewController1: UIViewController {
    @IBAction func btnDidTouch(sender: AnyObject) {
        var viewController = self.storyboard!.instantiateViewControllerWithIdentifier("ViewController2") as! UIViewController
        self.presentViewController(viewController, animated: true, completion: nil)
    }
}
class ViewController2: UIViewController {
    @IBAction func btnDidTouch(sender: AnyObject) {
        var viewController = self.storyboard!.instantiateViewControllerWithIdentifier("ViewController3") as! UIViewController
        self.presentViewController(viewController, animated: true, completion: nil)
    }
}
class ViewController3: UIViewController {
    @IBAction func btnDidTouch(sender: AnyObject) {
        var viewController = self.storyboard!.instantiateViewControllerWithIdentifier("ViewController4") as! UIViewController
        self.presentViewController(viewController, animated: true, completion: nil)
    }
}
class ViewController4: UIViewController {
    @IBAction func btnDidTouch(sender: AnyObject) {
        self.view.window?.rootViewController!.dismissViewControllerAnimated(true, completion: nil)
    }
}

      

+3
ios uiviewcontroller swift


source to share


No one has answered this question yet

Check out similar questions:

1300
Transferring data between view controllers
3
Changing the background color of the selected UITableViewCell
1
Disable View Manager in Modally Segue
0
Swift Segue programmatically
0
Unwind Segues not working
0
Swift ViewController without prepareForSegue
0
Xcode navigation not visible after button click
0
How can I pass data from UIViewController to UITabBarController?
0
The app crashes when I hit segue from one view controller to another and then try to go back to the first view controller
-4
Move to previous controller



All Articles
Loading...
X
Show
Funny
Dev
Pics