LoginSignup
2
1

More than 5 years have passed since last update.

[iOS] そもそもの元画面(rootViewController)を切り替える方法

Posted at

AppDelegateではなく、起動後にきれいさっぱりrootViewControllerを替えたかった。
調べたら、以下の方法があったので共有しておきます。

SwitchRootViewController.rb
// アニメーション
let vc = UIViewController() // 元画面にしたいビューコントローラ
UIApplication.shared.keyWindow?.rootViewController = vc

// アニメーションあり
UIView.transition(with: window, duration: 0.3, options: .transitionCrossDissolve, animations: {
    UIApplication.shared.keyWindow?.rootViewController = vc
}, completion: { completed in
    // maybe do something here
})

参考サイト
https://stackoverflow.com/questions/41144523/swap-rootviewcontroller-with-animation

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1