- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2016-05-30T14:44:03+09:00","default:wikiwriter","wikiwriter")
#author("2017-01-24T14:35:04+09:00","default:wikiwriter","wikiwriter")
&tag(UIKit/テーブル);
*目次 [#sc69111a]
#contents
*関連ページ [#pe99027a]
-[[Storyboard]]
-[[./基本]]
-[[./セルの再利用]]
-[[./セルのカスタマイズ]]
-[[./セルを共有する]]
-[[./Static Cellsを使用する]]
-[[./セル内に置かれたボタンのイベントを処理する]]
-[[./空状態を表現する]]
-[[./Tips]]
*参考情報 [#w10c3f1c]
*概要 [#e44ab7b1]
-Swiftでテーブルビューを実装する方法
*サンプル [#a8f334ba]
**UITableViewControllerの基礎 [#o6dfe1e6]
-三行のデータを表示するサンプル。
#pre{{
class TableViewBasicViewController: UITableViewController {
var rows = ["aaa", "bbb", "ccc"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return rows.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath)
cell.textLabel?.text = rows[indexPath.row]
return cell
}
}
}}