LoginSignup
0
1

More than 3 years have passed since last update.

UIViewControllerの全面にUITableViewを設置する場合、`UITableView`を基底viewにしてしまえばよさそう

Last updated at Posted at 2020-02-14

概要

  • UIViewControllerの全面にUITableViewを設置する場合、UITableViewを基底viewにしてしまえばよさそう
  • UIViewControllerviewインスタンス(基底view)がUITableViewのインスタンスになる

メリット

  • 管理するviewが一つ減る
  • AutoLayoutの制約が不要になる

デメリット

  • UITableView以外にViewを追加したいようなケースでは使えない
    • その場合はUIViewを基底viewにする必要がある

スクリーンショット

スクリーンショット 2020-02-14 16.34.53.png

手順

  1. StoryboardにUIViewControllerを設置
  2. 1.で設置したUIViewControllerの基底ViewをStoryboard上で削除する
  3. UITableViewを選択しドラッグアンドドロップで基底ViewとしてUIViewControllerに設置 スクリーンショット 2020-02-14 16.29.15.png

その他

  • 基本的にどんなViewも基底viewに設定できる
    • UITableViewCellUINavigationItemなど、他のView上に設置されるようなViewも設定できる
0
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
0
1