iOS 기본 (swift)
[iOS - swift] 디폴트 storyboard 없이 구현 방법 (스토리보드 없이 코딩 방법)
jake-kim
2021. 3. 21. 00:30
storyboard, SceneDelegate 제거
- storyboard 삭제
- Main.storyboard 삭제
- target의 main interface 에서 설정된 스토리보드 해제
- SceneDelegate 삭제
- info.plist에 Application Scene Manifest 삭제
- SceneDelegate.swift 삭제
- AppDelegate.swift에 UISsceneSession Lifecycle 관련 메소드 2개 삭제
구체적인 Main.storyboard 삭제 방법
- info.plist의 Main storyboard file base name 삭제

- Storyboard Name 삭제

- Main.storyboard 삭제

- AppDelegate.swift에 storyboard 없이 새로운 화면으로 UIWindow로 초기화
(storyboard 없이 코드로만 작업하는 경우나, 특정 ViewController를 초기화 화면으로 하고싶은 경우)
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = ViewController() // 특정 ViewController
window?.makeKeyAndVisible()
return true
}
...
}