LoginSignup
1
1

More than 5 years have passed since last update.

ContainerViewにEmbedされているViewControllerを変更する

Posted at

ContainerViewを使用すると、標準でViewControllerがついてくる。
これをTableViewControllerに変える方法。

環境

  • Xcode 7.1.1
  • Swift 2.1

背景

例えばスライドメニューとかをContainer Viewを使って実装する場合。
ViewControllerよりもTableViewControllerのStatic Cellsを使って簡単にメニューを作りたい。
ちなみにStatic CellsはTableViewControllerでしか使えない。

方法

  1. まずはContainer Viewを追加する(View ControllerがEmbedされる)
  2. EmbedされているView Controllerを削除する
  3. オブジェクトライブラリからTable View ControllerをStoryBoardにドラッグ&ドロップして追加する
  4. ContainerViewからCtrlを押しながらTableViewControllerに接続する
  5. ポップアップが表示されたら「Embed」を選択する

以上

1
1
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
1
1