How to go back to rootview controller in swift 5 where scenedelegate is available instead of Appdelegate
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// guard let _ = (scene as? UIWindowScene) else { return }
if let windowScene = scene as? UIWindowScene {
self.window = UIWindow(windowScene: windowScene)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController =
storyboard.instantiateViewController(withIdentifier: "first_page")
self.window!.rootViewController = initialViewController
self.window!.makeKeyAndVisible()
}
}
this is my scenedelegate code need to dismiss/popback to my first page.
i am having the first page in Main.storyboard but my logout function is in another storyboard called Home.storyboard
tried
self.view.window?.rootViewController?.dismiss(animated: true, completion: nil)
and
self.navigationController?.popToRootViewController(animated: true)
But not working i have only one navigation controller that is for the first viewcontroller