简体   繁体   中英

Dismiss PageViewController and load a new ViewController

i have been working on an pageViewController in swift and xcode. I used the default template in xcode and made a pageViewController application. But now i want to place a button on the pageViewController that shows on all pageViewControllers and when tapped that button the pageViewController dismissed and the RootViewController screen is shown back. I have written this line but this does nothing.

self.dismiss(animated: true, completion: nil)

But this is of no help. Can you please tell me how can i achieve this? Thank you.

You should use popToRootViewController() . You could have a nav bar with a button that calls this function so that whatever view you are currently on, it will pop to the rootviewcontroller.

In this case you can use container for your pageViewController. Should be something like this: 在此输入图像描述

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM