Swift カスタムセルの作り方

余談

久しぶりの投稿です。

ブログを定期的に更新するのはやはり難しいですね汗

 

今回の目的

Table View Controllerのセルをカスタマイズしよう

 

1. プロジェクト作成

2. Navigation Controllerを追加

Table View Controllerでも良いけど、今後の拡張のことを考えるとNavigation Controllerかなと思う。

3. セルの中にImage View, Labelをセット

f:id:protouyu:20151208234232p:plain

Navigation Controller の Is intial View Controller をチェックしておかないと最初に起動しないから注意

 

4. コードを書く

まず、Model.swift, CustomCell.swift, tableViewController.swiftを作成する

 

CustomCellとtableViewControllerをstoryboardで関連付けるのを忘れないように

また、CustomCellの関連付ける場所にも注意!

セルの中にあるPrototype Cellsの下くらいをクリック

 

画像は任意のもので良い

 

Model.swift

CustomCell.swift

tableViewController.swift

 

5. 完成系

f:id:protouyu:20151209005305p:plain