私はテーブルビューコントローラのセルに名前の配列を提示しようとしています。 TableViewコントローラ - スウィフト
import UIKit
class TableViewController: UITableViewController
{
var names = ["aA", "aB", "cC"]
override func numberOfSectionsInTableView(tableView: UITableView) -> Int
{
return 0
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return names.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("MyCell", forIndexPath: indexPath)
cell.detailTextLabel!.text = names[indexPath.row]
return cell
}
}
私はそれをシミュレート
は、何も細胞内に登場していない:私のコードに間違いがあります。 コンパイラは私にエラーを与えませんでした。
numberOfSectionsInTableView ... 1を返すか、完全に変更した後numberOfSectionsをそのメソッド –
を削除し、あなたのクラスにストーリーボードにビューをリンクするかどうかを確認します。 – UlyssesR
@EICaptainチェックデータソース/デリゲート*は、ここでは不要です。ここでは、 'UITableViewController'サブクラスを扱っています。 – nhgrif