swift
1import UIKit 2 3class TableViewController: UITableViewController { 4 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 9 tableView.backgroundColor = UIColor.redColor() 10 11 self.title = "ore" 12 13 // Uncomment the following line to preserve selection between presentations 14 // self.clearsSelectionOnViewWillAppear = false 15 16 // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 17 // self.navigationItem.rightBarButtonItem = self.editButtonItem() 18 } 19 20 override func didReceiveMemoryWarning() { 21 super.didReceiveMemoryWarning() 22 // Dispose of any resources that can be recreated. 23 } 24 25 // MARK: - Table view data source 26 27 override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 28 // #warning Incomplete implementation, return the number of sections 29 return 1 30 } 31 32 override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 33 // #warning Incomplete implementation, return the number of rows 34 return 1 35 } 36 37 /* 38 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 39 let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) 40 41 // Configure the cell... 42 43 return cell 44 } 45 */ 46 47 /* 48 // Override to support conditional editing of the table view. 49 override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 50 // Return false if you do not want the specified item to be editable. 51 return true 52 } 53 */ 54 55 /* 56 // Override to support editing the table view. 57 override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 58 if editingStyle == .Delete { 59 // Delete the row from the data source 60 tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) 61 } else if editingStyle == .Insert { 62 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 63 } 64 } 65 */ 66 67 /* 68 // Override to support rearranging the table view. 69 override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { 70 71 } 72 */ 73 74 /* 75 // Override to support conditional rearranging of the table view. 76 override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { 77 // Return false if you do not want the item to be re-orderable. 78 return true 79 } 80 */ 81 82 /* 83 // MARK: - Navigation 84 85 // In a storyboard-based application, you will often want to do a little preparation before navigation 86 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 87 // Get the new view controller using segue.destinationViewController. 88 // Pass the selected object to the new view controller. 89 } 90 */ 91 92} 93
storybordにあるラベル2つを上記のファイルにoutletしたとして、
よくみるcell.textLabel.text = ""というような書き方ができないと思います。
この場合にセルの中のラベルに値を入れる書き方ってどうなりますか?
サブクラスでUITableViewCellを継承して、そっちにoutletしろみたいなこともありましたが、
うまくいきません。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/03/21 03:16
2016/03/21 03:26
2016/03/21 06:59