对成员 'tableView(_:numberOfRowsInSection:)' 的引用不明确

Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'

想将数据从具有 TableView init 的 ViewController 传递到另一个 ViewController。但它向我显示错误 "Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)' "

@IBOutlet weak var completedCaseTableView: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()

    completedCaseTableView.delegate = self
    completedCaseTableView.dataSource = self

    // Do any additional setup after loading the view.
}


public func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return usrNameList.count
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CompletedCaseCell", for: indexPath) as! Admin_CompletedCases_TableViewCell

    cell.completedTktNum.text = usrTktList[indexPath.row]
    cell.completedUsrName.text = usrNameList[indexPath.row]

    cell.completedCustomerDp.image = UIImage(named: imageList[indexPath.row])

    cell.completedPostedDate.text = datesList[indexPath.row]
    cell.completedUsrReason.text = reasonList[indexPath.row]
    cell.statusOfCase.text = statusList[indexPath.row]



    return cell
}

public override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    if (segue.identifier == "AdminCompletedDetailsSegue" ){

        let adminCompletedDvc = segue.destination as! Admin_Completed_Details_ViewController

        if let indexPath = self.tableView.indexPathForSelectedRow {

            adminCompletedDvc.newTktNumNew = usrTktList[indexPath.row] as String

            adminCompletedDvc.customerUsernameAdmnNew = usrNameList[indexPath.row] as String

            adminCompletedDvc.postedDateAdmnNew = datesList[indexPath.row] as String

            adminCompletedDvc.customerReasonAdmnNew = reasonList[indexPath.row] as String

            adminCompletedDvc.customerCommentsAdmnNew = commentList[indexPath.row] as String

            adminCompletedDvc.customerImgAdmnNew = imageList[indexPath.row] as String

        }

    }
}

问题是您的视图控制器中没有名为 self.tableView 的任何内容。它的名字是completedCaseTableView。所以改变这个:

if let indexPath = self.tableView.indexPathForSelectedRow {

对此:

if let indexPath = self.completedCaseTableView.indexPathForSelectedRow {