LoginSignup
0
0

More than 5 years have passed since last update.

[tvOS]独自のコンテナViewController

Posted at

tvOSでも、TabBarControllerやNavigationControllerは使えるが、TVのユーザインタフェースということを考えると、独自のコンテナViewControllerが必要になる場合があると思う。そこで、以前、iOS向けに検討したコンテナViewControllerをtvOSに組み込んでみた。

Title.jpg

コンテナビューコントローラに子ビューコントローラを登録。

self.addChildViewController(titleViewController!)
self.addChildViewController(gameViewController!)

最初の画面を表示させる。

selectedViewController = titleViewController
self.view.addSubview(selectedViewController!.view)

画面を切り替えるコード。

    func toGameViewController() {
        transitionFromViewController(titleViewController!, toViewController: gameViewController!, duration: 1.0, options: .TransitionCrossDissolve, animations: nil, completion: { (finished: Bool) -> Void in self.selectedViewController = self.gameViewController })
    }

ソースコード
GitHubからどうぞ。

https://github.com/murakami/workbook/tree/master/tvos/Pokopen - GitHub

関連情報
Cocoa Advent Calendar 2015

[iOS]独自のコンテナViewController

【Cocoa練習帳】
http://www.bitz.co.jp/weblog/

http://ameblo.jp/bitz/(ミラー・サイト)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0