概要
テーブルビューで呼ばれるはずのtableview関数がよばれず、テーブルビューの中身が表示されません
該当のソースコード
import UIKit import Firebase class ViewController: UIViewController,UITableViewDataSource { var documents : Array<QueryDocumentSnapshot?> = [] @IBOutlet weak var work1tableview: UITableView! func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if tableView == work1tableview{ print(documents.count) return documents.count } return 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { // if tableView == work1tableview{ //呼ばれない print("c") let a = documents[indexPath.row]?.data()["name"] as? String let b = documents[indexPath.row]?.data()["work1"] as? String let caa = documents[indexPath.row]?.data()["work2"] as? String ?? "" let ca = " " + caa let cai = documents[indexPath.row]?.data()["work3"] as? String ?? "" let c = ca + " " + cai ?? "" let da = documents[indexPath.row]?.data()["eschool"] as? String ?? "" + " " let di = documents[indexPath.row]?.data()["cschool"] as? String ?? "" let d = da + di + " " let e = b ?? "" + c let f = documents[indexPath.row]?.data()["univercity"] as? String ?? "" let fi = documents[indexPath.row]?.data()["hschool"] as? String ?? "" let fu : String if documents[indexPath.row]?.data()["apokn"] as? Bool == true { let fu = "必要" let fa = " " + f + "取材許可:" + fu let cell = tableView.dequeueReusableCell(withIdentifier: "w1cell") cell?.textLabel?.text = a ?? "" + " " + e cell?.detailTextLabel?.text = "出身校:" + d + fi + fa print("aa") return cell! }else{ let fu = "不必要" let fa = " " + f + "取材許可:" + fu let cell = tableView.dequeueReusableCell(withIdentifier: "w1cell") cell?.textLabel?.text = a ?? "" + " " + e cell?.detailTextLabel?.text = "出身校:" + d + fi + fa print("aaa") return cell! } // }
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー