LoginSignup
4
4

More than 5 years have passed since last update.

UITableViewController/UITableViewの実装メモまとめ

Last updated at Posted at 2016-04-05

UITableViewの実装メモのまとめです。

ViewControllerとUITableViewのデータの紐付け

ViewControllerにUITableViewDataSource、UITableViewDelegateを継承

ViewController.swift
class ViewController.swift : UIViewController, UITableViewDataSource, UITableViewDelegate {

Storyboardでdatasourseとdelegateを設定

TBD

一覧のセルに動的に情報を設定/表示する

ViewController.swift
func tableView(table: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        // Storyboardで設定したTable View CellのIdentifierを設定し、
        // Cellに設定するコンポーネントのレンダリング処理を実装
        let cell = table.dequeueReusableCellWithIdentifier("", forIndexPath: indexPath)
        return cell
}

一覧選択時のイベント

ViewController.swift
func tableView(table: UITableView, didSelectRowAtIndexPath indexPath:NSIndexPath) {
        // 一覧のCell選択時イベント内容を実装
}

編集モードがある一覧の実装

TBD

参考

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