Upgrade to Pro — share decks privately, control downloads, hide ads and more …

既存アプリをiPadOSで複数Window対応/multi_windows_on_ipados

 既存アプリをiPadOSで複数Window対応/multi_windows_on_ipados

令和最初のDeveloper's Living 〜WWDC2019〜( https://lifull.connpass.com/event/135446/ )というイベントで登壇してきた内容です。
iPadOSで複数ウィンドウに対応する方法を発表しました。

fromkk

June 28, 2019
Tweet

More Decks by fromkk

Other Decks in Programming

Transcript

  1. 1SPpMF struct Profile { let name = "Kazuya Ueoka" let

    twitter = "@fromkk" let github = "fromkk" let qiita = "fromkk" let company = "Timers Inc." } •
  2. *OGPQMJTU <key>UIApplicationSceneManifest</key> <dict> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>

    <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UILaunchStoryboardName</key> <string>LaunchScreen.storyboard</string> </dict> </array> </dict> <key>UIApplicationSupportsMultipleScenes</key> <true/> </dict>
  3. "QQ%FMFHBUFʹ௥ه @available (iOS 13.0, *) func application(_ application: UIApplication, configurationForConnecting

    connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { return UISceneConfiguration(name: "Default Configuration”, sessionRole: connectingSceneSession.role) } ˞OBNF͸*OGPQMJTUʹهड़ͨ͠6*4DFOF$POpHVSBUJPO/BNFͱ߹ΘͤΔ
  4. 4DFOF%FMFHBUF import UIKit @available(iOS 13.0, *) final class SceneDelegate: UIResponder,

    UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo _: UISceneSession, options _: UIScene.ConnectionOptions) { let rootViewController = RootViewController() let window = UIWindow(windowScene: scene as! UIWindowScene) window.rootViewController = rootViewController window.backgroundColor = .systemBackground window.makeKeyAndVisible() self.window = window } }
  5. J04ҎԼΛ౿·࣮͑ͨ૷ͷߟ͑ํ w 4VQQPSUTNVMUJQMFXJOEPXTʹνΣοΫΛೖΕΔ w దٓ*OGPQMJTUΛमਖ਼ w 4DFOF%FMFHBUFTXJGUΛ࡞੒ˍ"QQ%FMFHBUFʹϝιου௥Ճ !BWBJMBCMF J04 

     w "QQ%FMFHBUFTXJGUͱॲཧΛڞ௨Խ Ұ౓͔͠ݺ͹Εͨ͘ͳ͍΋ͷͳͲʹ ஫ҙ͕ඞཁ  w ෳ਺8JOEPXಠࣗͷػೳͳͲΛ࣮૷͍ͯ͘͠
  6. ڞ௨Ϋϥεͷྫ import UIKit final class AppEventHandler { @available(iOS 13.0, *)

    func createWindow(with windowScene: UIWindowScene) -> UIWindow { let window = UIWindow(windowScene: windowScene) window.backgroundColor = UIColor.systemBackground configureRootViewController(for: window) return window } func createWindow() -> UIWindow { let window = UIWindow(frame: UIScreen.main.bounds) window.backgroundColor = .white configureRootViewController(for: window) return window } private func configureRootViewController(for window: UIWindow) { window.rootViewController = UIViewController() } func willEnterForeground() {} func didBecomeActive() {} func willResignActive() {} func didEnterBackground() {} }
  7. 4DFOF%FMFHBUFͷྫ import UIKit @available(iOS 13.0, *) class SceneDelegate: UIResponder, UIWindowSceneDelegate

    { var window: UIWindow? lazy var appEventHandler = AppEventHandler() func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { if let windowScene = scene as? UIWindowScene { window = appEventHandler.createWindow(with: windowScene) window?.makeKeyAndVisible() } } func sceneDidDisconnect(_ scene: UIScene) {} func sceneDidBecomeActive(_ scene: UIScene) { appEventHandler.didBecomeActive() } func sceneWillResignActive(_ scene: UIScene) { appEventHandler.willResignActive() } func sceneWillEnterForeground(_ scene: UIScene) { appEventHandler.willEnterForeground() } func sceneDidEnterBackground(_ scene: UIScene) { appEventHandler.didEnterBackground() } }
  8. "QQ%FMFHBUFͷྫ import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var

    window: UIWindow? lazy var appEventHandler = AppEventHandler() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if #available(iOS 13.0, *) {} else { window = appEventHandler.createWindow() window?.makeKeyAndVisible() } return true } func applicationWillTerminate(_ application: UIApplication) {} func applicationWillEnterForeground(_ application: UIApplication) { if #available(iOS 13.0, *) {} else { appEventHandler.willEnterForeground() } } func applicationDidBecomeActive(_ application: UIApplication) { if #available(iOS 13.0, *) {} else { appEventHandler.didBecomeActive() } } func applicationWillResignActive(_ application: UIApplication) { if #available(iOS 13.0, *) {} else { appEventHandler.willResignActive() } } func applicationDidEnterBackground(_ application: UIApplication) { if #available(iOS 13.0, *) {} else { appEventHandler.didEnterBackground() } } // MARK: UISceneSession Lifecycle @available(iOS 13.0, *) func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } @available(iOS 13.0, *) func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {} }
  9. 13

  10. • αʔόʔαΠυΤϯδχΞ (PHP, Golang, AWS) • AndroidΤϯδχΞ (Kotlin) • iOSΤϯδχΞ

    (Swift) TimersͰ͸ݱࡏΤϯδχΞશ৬छ࠾༻தʂ
 ৄ͘͠͸”Timers”Ͱݕࡧ