iOS를 사용하여 프로젝트에서 Main을 시작합니다.storyboard 삭제, 코드로 Rot ViewController 생성

6637 단어 iOSSwiftuikittech
iOS를 사용하여 프로젝트에서 Main을 시작합니다.storyboard에서 코드로 Rot의 ViewController를 생성하는 방법의 노트를 삭제합니다.

절차.


  • 프로젝트에서 제거Main.storyboard
  • Info.plist에서 storyboard에 대한 기술을 삭제합니다


  • diff --git a/uikit-architecture/Info.plist b/uikit-architecture/Info.plist
    index 5b531f7..2688b32 100644
    --- a/uikit-architecture/Info.plist
    +++ b/uikit-architecture/Info.plist
    @@ -33,8 +33,6 @@
                                            <string>Default Configuration</string>
                                            <key>UISceneDelegateClassName</key>
                                            <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
    -                                       <key>UISceneStoryboardFile</key>
    -                                       <string>Main</string>
                                    </dict>
                            </array>
                    </dict>
    @@ -43,8 +41,6 @@
            <true/>
            <key>UILaunchStoryboardName</key>
            <string>LaunchScreen</string>
    -       <key>UIMainStoryboardFile</key>
    -       <string>Main</string>
            <key>UIRequiredDeviceCapabilities</key>
            <array>
                    <string>armv7</string>
    
  • SceneDelegate.swift ViewController 코드를 추가로 생성
  • diff --git a/uikit-architecture/SceneDelegate.swift b/uikit-architecture/SceneDelegate.swift
    index 73be64c..275dc67 100644
    --- a/uikit-architecture/SceneDelegate.swift
    +++ b/uikit-architecture/SceneDelegate.swift
    @@ -16,7 +16,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
             // 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: UIScreen.main.bounds)
    +        window?.rootViewController = ViewController()
    +        window?.makeKeyAndVisible()
    +        window?.windowScene = windowScene
    
    상술한 항목은 이미 우리측에 추천되었다.
    https://github.com/yorifuji/uikit-architecture
    MVC와 MVP 등의 디자인을 배울 때 이런 종목을 원하게 된다.

    좋은 웹페이지 즐겨찾기