LoginSignup
6
5

More than 5 years have passed since last update.

UIViewControllerにUITableViewのStatic Cellsを配置する方法

Last updated at Posted at 2017-01-04

UIViewControllerにUITableViewを配置し、Static Cellsを設定すると下記のようにエラーが出てビルド出来ません。

error.png

Static CellsはUITableViewControllerでのみ使用できます。
ですのでこの記事では代替案として、UIViewControllerにContainer Viewを配置し、Container Viewの中にUITableViewControllerを配置することでStatic Cellsを使えるようにしています。

手順

UIViewControllerにContainer Viewを設置

setContainerView.png
自動的に生成されるViewControllerは削除してください。

UITableViewControllerを設置

setTableViewController.png

接続

最後に、Control+ドラッグでContainer ViewからUITableViewControllerにEmbed接続します。
embed.png

完成

complete.png
Static Cellsにしてもエラーが出なくなりました。

6
5
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
6
5