私はInterface BuilderのビューにUITableView
を追加したiOSアプリケーションを持っています。そして、私はこのようなUIViewController
でテーブルビューを設定します。テーブルビューのメソッドが呼び出されることはありません
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 50
tableView.delegate = self
tableView.dataSource = self
tableView.contentInset = UIEdgeInsets(top: 25, left: 0, bottom: 0, right: 0)
そして、私はまた、次のメソッド実装:ただし、メソッドが呼び出されることはありません
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("test table")
let course = self.courses[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: CourseTableViewCell.identifier, for: indexPath) as! CourseTableViewCell
cell.make(course, location: self.currentLocation)
return cell
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return courses.count
}
を、テーブルビューが表示されていません私のコンソールにエラーはありませんか?私はこれを追加しようとしている間に逃したものがありますか?
ありがとうございました。コメントでリクエストを1として
:
courses
配列はcourses
配列がreloadData()
IBOutletとしてコードにTableViewをリンクしましたか? –
@ReinierMelianはい、リンクされています: '@IBOutlet weak var tableView:UITableView!' –
'tableView.reloadData()'はどこで呼び出しますか? – vadian