Swiftで遊ぼう! on Hatena

あしたさぬきblogでやってた初心者オヤジのiOSプログラミング奮闘記がHatenaに来ました

Swiftで遊ぼう! - 470 - Navigation Controllers and Table Views 10

Swiftで遊ぼう!の古い記事-> Life-LOG OtherSide

Beginning iPhone Development with Swift: Exploring the iOS SDK

Beginning iPhone Development with Swift: Exploring the iOS SDK

じっくりゆっくりコーディングしてます。

テーブルビューの必須デリゲーションメソッドは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の用意です。

では明日。