본문 바로가기

iOS

[Swift] Storyboard 없이 코드로 프로젝트 시작하기

반응형

1. Main.storyboard 삭제

2. Targets -> General 에서 Main Interface 삭제

3. info.plist -> Application Scene Manifest -> Storyboard Name 삭제

4. SceneDelegate -> func scene을 아래 내용으로 대체, ViewController() //시작 뷰

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 }
    guard let windowScene = (scene as? UIWindowScene) else { return }
    window = UIWindow(frame: windowScene.coordinateSpace.bounds)
    window?.windowScene = windowScene
    window?.rootViewController = ViewController()
    window?.makeKeyAndVisible()
}

'iOS' 카테고리의 다른 글

[Swift] SnapKit  (0) 2021.12.15
[Swift] Lazy 변수  (0) 2021.12.15
[Swift] UI 화면 안나타남  (0) 2021.10.22
[Swift] 화면전환 방법 - 코드  (0) 2021.10.20
[Swift] 선택정렬 코드  (0) 2021.10.19