Swiftで遊ぼう! - 470 - Navigation Controllers and Table Views 10
Swiftで遊ぼう!の古い記事-> Life-LOG OtherSide
Beginning iPhone Development with Swift: Exploring the iOS SDK
- 作者: David Mark,Jack Nutting,Kim Topley,Fredrik Olsson,Jeff LaMarche
- 出版社/メーカー: Apress
- 発売日: 2014/11/19
- メディア: Kindle版
- この商品を含むブログを見る
じっくりゆっくりコーディングしてます。
テーブルビューの必須デリゲーションメソッドは2つあり今のところ1つ実装しています。
最後に最も重要なメソッド、cellを呼ぶメソッドです。呼ぶというよりはidentifierを使って、プロトタイプのcellを実体化(インスタンス化)するメソッドです。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { if indexPath.section == 0 { let cell = tableView.dequeueReusableCellWithIdentifier(familyCell, forIndexPath: indexPath) cell.textLabel?.font = fontForDisplay(atIndePath: indexPath) cell.textLabel?.text = familyNames[indexPath.row] cell.detailTextLabel?.text = familyNames[indexPath.row] return cell } else { let cell = tableView.dequeueReusableCellWithIdentifier(favoritesCell, forIndexPath: indexPath) return cell } }
これでRootViewControllerの実装はできました。次はMain.storyboardを使ってcellの用意です。
では明日。