UIKit/テーブル/セルの再利用
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[UIKit/テーブル]]
&tag(UIKit/テーブル/セルの再利用);
*目次 [#mc083a7a]
#contents
*関連ページ [#pa4b278b]
*参考情報 [#q80d681b]
*概要 [#zd79fab7]
-cellForRowAtIndexPathで毎回UITableViewCellを生成している...
-これを回避するための方法
-参考: [[iOS6 UITableViewのセルの再利用の方法が変わった ...
-[[UITableViewのセルの使いまわしについて – Morizotter Blo...
*iOS 6以降: registerClassとdequeueReusableCellWithIdentif...
-以下のようにあらかじめregisterClassで登録する
#pre{{
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.contentInset = UIEdgeInsets(top: 2...
self.tableView.registerClass(UITableViewCell.self...
}
func tableView(tableView: UITableView, cellForRowAtIn...
// 素直にCellのインスタンスを生成することもできる。
// let cell = UITableViewCell(style: UITableViewCe...
let cell = tableView.dequeueReusableCellWithIdent...
cell.textLabel?.text = rows[indexPath.row]
return cell
}
}}
※ストーリーボードで設定したプロトタイプセルを利用する場合...
* iOS 6より前: dequeueReusableCellWithIdentifierを使う [#...
-iOS 6以後でも使うことができる。CellのStyleを指定したい場...
#pre{{
func tableView(tableView: UITableView, cellForRowAtIn...
var cell = tableView.dequeueReusableCellWithIdent...
if (cell == nil) {
cell = UITableViewCell(style: UITableViewCell...
}
let theCell = cell!
theCell.textLabel?.text = rows[indexPath.row]
return theCell
}
}}
*トラブルシューティング [#ycf7d5cb]
**reason: 'unable to dequeue a cell with identifier Cell ...
-メッセージ通りプロトタイプセルにidentifierが設定されてい...
-Table View ControllerのPrototype Cellsを選択し、Identity...
終了行:
[[UIKit/テーブル]]
&tag(UIKit/テーブル/セルの再利用);
*目次 [#mc083a7a]
#contents
*関連ページ [#pa4b278b]
*参考情報 [#q80d681b]
*概要 [#zd79fab7]
-cellForRowAtIndexPathで毎回UITableViewCellを生成している...
-これを回避するための方法
-参考: [[iOS6 UITableViewのセルの再利用の方法が変わった ...
-[[UITableViewのセルの使いまわしについて – Morizotter Blo...
*iOS 6以降: registerClassとdequeueReusableCellWithIdentif...
-以下のようにあらかじめregisterClassで登録する
#pre{{
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.contentInset = UIEdgeInsets(top: 2...
self.tableView.registerClass(UITableViewCell.self...
}
func tableView(tableView: UITableView, cellForRowAtIn...
// 素直にCellのインスタンスを生成することもできる。
// let cell = UITableViewCell(style: UITableViewCe...
let cell = tableView.dequeueReusableCellWithIdent...
cell.textLabel?.text = rows[indexPath.row]
return cell
}
}}
※ストーリーボードで設定したプロトタイプセルを利用する場合...
* iOS 6より前: dequeueReusableCellWithIdentifierを使う [#...
-iOS 6以後でも使うことができる。CellのStyleを指定したい場...
#pre{{
func tableView(tableView: UITableView, cellForRowAtIn...
var cell = tableView.dequeueReusableCellWithIdent...
if (cell == nil) {
cell = UITableViewCell(style: UITableViewCell...
}
let theCell = cell!
theCell.textLabel?.text = rows[indexPath.row]
return theCell
}
}}
*トラブルシューティング [#ycf7d5cb]
**reason: 'unable to dequeue a cell with identifier Cell ...
-メッセージ通りプロトタイプセルにidentifierが設定されてい...
-Table View ControllerのPrototype Cellsを選択し、Identity...
ページ名: