- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2016-07-15T16:33:19+09:00","default:wikiwriter","wikiwriter")
#author("2016-07-20T11:25:53+09:00","default:wikiwriter","wikiwriter")
[[UIKit/テーブル]]
&tag(UIKit/テーブル/セルを共有する);
*目次 [#nd29c1a3]
#contents
*関連ページ [#vfcb04a9]
*参考情報 [#w38fcfeb]
-[[NibからCellを作って使いまわしてUITableViewCellを楽々カスタマイズ! – Morizotter Blog:http://blog.morizotter.com/2013/01/23/the-easiest-way-to-make-custamcell-with-xib/]]
*概要 [#v51ed55d]
-xibファイルにセルを作成。
-xibファイルにTable View Cellをドロップ。そのクラスをUITableViewCellのカスタムクラスに変更。
-registerNibで登録。
#pre{{
override func viewDidLoad() {
super.viewDidLoad()
let nib = UINib(nibName: "ShareCell", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "shareCell")
}
}}
-普通に使用する。
#pre{{
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("shareCell", forIndexPath: indexPath) as! ShareCell
cell.label.text = rows[indexPath.row]
return cell
}
}}