方法不会覆盖其超类中的任何方法-索引路径上的行单元格



我试过删除覆盖和派生数据,重新编写单元格行索引路径函数,重新编写单元格变量结构,没有运气。任何想法?

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return BPC.count
}
override  func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "BPCCell") as! BPC_TableCell
    cell.namelabel.text = BPC[indexPath.row].name
    cell.addresslabel.text = BPC[indexPath.row].address
    return cell  
}
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "BPCsegue" {
        if let destViewControler = segue.destinationViewController as? BPCDetails {
            let indexPath = self.tableView.indexPathForSelectedRow!
            destViewControler.details = BPC[indexPath.row]
        }
    }
}

cell for row at index path这样的方法只有在子类化UITableViewController时才使用override关键字。如果您遇到无法覆盖某个方法的问题,那么您很可能没有创建正确的类的子类。

最新更新