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

多次元宇宙と画面遷移

haranicle
September 16, 2017

 多次元宇宙と画面遷移

haranicle

September 16, 2017
Tweet

More Decks by haranicle

Other Decks in Technology

Transcript

  1. Y

  2. Y Z

  3. Y

  4. Y [

  5. class RootViewController: UIViewController { enum State { case splash case

    home } private var currentViewController: UIViewController? func switchState(to state: State) { if let vc = currentViewController { vc.willMove(toParentViewController: nil) vc.view.removeFromSuperview() vc.removeFromParentViewController() } switch state { case .splash: currentViewController = SplashViewController() case .home: currentViewController = homeNavigationViewController } addChildViewController(currentViewController!) view.addSubview(currentViewController!.view) currentViewController!.didMove(toParentViewController: self) } let homeNavigationViewController = UINavigationController(rootViewController: HomeViewController() } TUBUFʹԠͯ͡ DIJME7JFX$POUSPMMFSΛ εΠον͢Δ
  6. class RootViewController: UIViewController { enum State { case splash case

    home } private var currentViewController: UIViewController? func switchState(to state: State) { if let cvc = currentViewController { cvc.willMove(toParentViewController: nil) cvc.view.removeFromSuperview() cvc.removeFromParentViewController() } switch state { case .splash: currentViewController = SplashViewController() case .home: currentViewController = homeNavigationViewController } addChildViewController(currentViewController!) view.addSubview(currentViewController!.view) currentViewController!.didMove(toParentViewController: self) } let homeNavigationViewController = UINavigationController(rootViewController: HomeViewController()) } υϦϧμ΢ϯͷ֊૚Λҡ͍࣋ͨ͠ 7JFX$POUSPMMFS͸ εΠονͰഁغ͞Εͳ͍Α͏ʹ͢Δ
  7. class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? let rootViewController

    = RootViewController() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { window = UIWindow() window?.rootViewController = rootViewController window?.makeKeyAndVisible() return true } func somethingHappens() { rootViewController.switchState(to: .home) }
 } 3PPU7JFX$POUSPMMFSΛ͓࣋ͬͯ͘ ద౰ͳλΠϛϯάͰTUBUFΛ੾Γସ͑Δ
  8. rootViewController.switchState(to: .home) let vcList = [ FirstViewController(), SecondViewController() ] rootViewController.homeNavigationViewController.setViewControllers(

    vcList, animated: false) 3PPU7JFX$POUSPMMFSͷεΠον υϦϧμ΢ϯͷߏங υϦϧμ΢ϯͷ֊૚ҡ࣋ͨ͠7JFX$POUSPMMFS