iOS13으로 업데이트 되면서 Scene delegate 라는것이 생겼었다.
새로 학습할 시간도 없고 내용파악도 귀찮아서
info.plist의
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
를 지워버리고
AppDelegate의
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
를 날려버려서 기존 AppDelegate만 있을 때 와 동일하게 프로젝트를 생성, 관리했었으나
이제는 SceneDelegate에 대하여 정확히 이해하고 사용하려고 메모를 남긴다.
골자는 iOS13부터 멀티 window를 지원하므로
앱이 백그라운드로 떨어지는것, 다시 올라오는것 등의 UI변화를 SceneDelegate로 이관한다는 것.
크게 변하는것 없이 기존 AppDelegate didFinish~ 에 구현하던 초기화 코드를
SceneDelegate wiillConnet~ 으로 옮겨준다.
나는 navigationController를 앱 전역에서 자주 접근하므로
appdelegate에 nav con을 만들어 두고
Scene에서 아래와 같이 구현,
APP.nav = UINavigationController.init(rootViewController: vc)
APP.nav.setNavigationBarHidden(true, animated: false)
APP.nav.modalPresentationStyle = .fullScreen
self.window?.rootViewController = APP.nav
self.window?.makeKeyAndVisible()
SceneDelegate로 전환 후 APP.window 접근 에러가 발생하는데
https://xodhks0113.blogspot.com/2020/03/ios13-window-scenedelegate.html
iOS13 window 접근 에러 (SceneDelegate 변경 접근하기)
iOS 개발 및 일상에 대한 블로그 입니다.
xodhks0113.blogspot.com
를 참고하여 해결.
'Programing' 카테고리의 다른 글
[XCODE][iOS][SWIFT] Storyboard 기반프로젝트에서 SwiftUI사용하기 (0) | 2023.07.20 |
---|---|
node js 죽지않게 돌리는법 (0) | 2023.07.13 |
AWS/Ubuntu EC2 셋팅 (0) | 2023.06.30 |
[iOS] 상단 Safety Area 영역 (2) | 2022.02.18 |
[iOS] WKWebview User Agent 설정 (0) | 2022.02.18 |