LoginSignup
1
1

More than 1 year has passed since last update.

Storyboardを無効化する

Last updated at Posted at 2022-04-29

やること

  • main.storybordの削除
  • .xcodeprojの編集
  • Info.plistの編集
  • SceneDelegate.swiftの編集

main.storybordの削除

main.storybordを削除するだけ

.xcodeprojの編集

General > Deployment Info

Main Interface を空にする
image.png

Info.plistの編集

Information Property List > Application Scene Manifest > Scene Configuration > Application Session Role > Item 0

Storyboard Nameを削除
image.png

SceneDelegate.swiftの編集

SceneDelegate内のwindowはstoryboardを使う場合、自動で初期化されている

storybordを無効化したことでwindowが初期化されなくなるため

rootViewControllerを指定して初期化する必要がある

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
        let window = UIWindow(windowScene: windowScene)
        window.rootViewController = ViewController.init()
        self.window = window
        window.makeKeyAndVisible()
    }

	//以下略
}
1
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
1
1