Last active
January 29, 2016 08:07
-
-
Save gitbricho/42aa8d5dad2954363a7d to your computer and use it in GitHub Desktop.
xcodeの使い方
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class MyTableViewController: UITableViewController { | |
// MARK:プロパティ | |
let items:[String] = ["項目1","項目2","項目3"] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// プレゼンテーション中に選択を維持するにはコメントを取る | |
// self.clearsSelectionOnViewWillAppear = false | |
// このビューコントローラのナビゲーション・バーで | |
// 編集ボタンを表示する場合はコメントを取る | |
// self.navigationItem.rightBarButtonItem = self.editButtonItem() | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
// MARK:テーブルビュー・データソース | |
override func tableView(tableView: UITableView , | |
cellForRowAtIndexPath indexPath: NSIndexPath ) -> UITableViewCell { | |
// テーブルビュー・セルは再利用されセル識別子を使って dequeued する. | |
let cellIdentifier = "MyTableViewCell" | |
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) | |
let item = items[indexPath.row] | |
cell.textLabel?.text = item | |
return cell | |
} | |
override func tableView(tableView: UITableView, | |
numberOfRowsInSection section: Int ) -> Int { | |
return items.count | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment