Swift

Swift 스토리보드없이 코드로 UI작업하기

지용빡 2022. 3. 23. 19:41
반응형
Swift 스토리보드없이 UI작업하기
Main.storyboard 삭제
  • 코드로 UI작업을 할거기 때문에 스토리보드를 삭제를 합니다. 
Storyboard Name 삭제
  • plist에서 Storyboard Name을 삭제해줍니다.

SceneDelegate에 rootViewController 등록
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        
        guard let windowScene = scene as? UIWindowScene else { return }
        self.window = UIWindow(windowScene: windowScene)
        
        let layout = UICollectionViewFlowLayout()
        let homeViewController = HomeViewController(collectionViewLayout: layout)
        let rootNavigationController = UINavigationController(rootViewController: homeViewController)
        
        self.window?.rootViewController = rootNavigationController
        self.window?.makeKeyAndVisible()
    }
Could not find a storyboard named 'Main' in bundle NSBundle
  • 위와 같은 오류가 발생 시 General에 가셔서 Main Interface에 Main이란 체크되있으면 지워주시면 됩니다.

반응형