对成员“tableView(_:numberOfRowsInSection:)"的不明确引用 [英] Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'

查看:59
本文介绍了对成员“tableView(_:numberOfRowsInSection:)"的不明确引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要将数据从具有 TableView init 的 ViewController 传递到另一个 ViewController.但它向我展示了错误对成员'tableView(_:numberOfRowsInSection:)'的不明确引用"

Wanna pass data from a ViewController which has TableView init, to another ViewController. But it's showing me the error "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.所以改变这个:

The problem is that there is nothing in your view controller called self.tableView. Its name is completedCaseTableView. So change this:

if let indexPath = self.tableView.indexPathForSelectedRow {

为此:

if let indexPath = self.completedCaseTableView.indexPathForSelectedRow {

这篇关于对成员“tableView(_:numberOfRowsInSection:)"的不明确引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆