简体   繁体   English

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

[英]Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'

Wanna pass data from a ViewController which has TableView init, to another ViewController.想要将数据从具有 TableView init 的 ViewController 传递到另一个 ViewController。 But it's showing me the error "Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)' "但它向我显示了错误“对成员 '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

        }

    }
}

即使在 Viewcontroller 中将 tableview 添加到 tableview 到 Delegate 和 Datasource 以及 @IBOUTLET 之后,仍然会遇到此问题

The problem is that there is nothing in your view controller called self.tableView .问题是你的视图控制器中没有任何东西叫做self.tableView Its name is completedCaseTableView .它的名字是completedCaseTableView So change this:所以改变这个:

if let indexPath = self.tableView.indexPathForSelectedRow {

to this:对此:

if let indexPath = self.completedCaseTableView.indexPathForSelectedRow {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM