func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell でUITableViewのセルを作っているのですが、indexPath.rowの値が全ての行に対して0になってしまいます。
Swift
1import UIKit 2 3class TableViewController: UITableViewController { 4 @IBOutlet var tabelView: UITableView! 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 } 9 10 override func didReceiveMemoryWarning() { 11 super.didReceiveMemoryWarning() 12 } 13 override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 14 // #warning Incomplete implementation, return the number of sections 15 return 4 16 } 17 18 override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 19 // #warning Incomplete implementation, return the number of rows 20 return 1 21 } 22 23 24 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 25 let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 26 cell.textLabel?.text = "内容"; 27 print(indexPath) 28 29 return cell 30 } 31}
Q1. これビルド出来るソースからのコピペですか?
Q2. numberOfRowsInSectionはどうなってますか?
Q3. ログに複数行の 0 が表示されているのでしょうか?
A1. ソースコードをビルドできるものに更新しました。
A2. numberOfRowsInSectionはソースコードにある通り1にしています。
A3. ログに複数行の0が表示されています
回答1件
あなたの回答
tips
プレビュー