2016-11-15 77 views
-1

即使更改新的swift3.0语法(如删除NS前缀和其他语法),也会发生错误。错误说Swift 3与tableView的错误

不能调用非功能型UITableView

我很高兴的价值,如果我能有解决这个问题的提示。

 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { 

       let cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath) 
       return cell 
     } 

回答

1
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "cartcel", for: indexPath) as! cartTableViewCell // My custom tableview cell class 
     cell.productName.text = Addtocartdata[indexPath.row].cartproName 
     cell.productQty.text = Addtocartdata[indexPath.row].cartproPrice 
     cell.productAmount.text = Addtocartdata[indexPath.row].cartproPrice 
     return cell; 
} 
+0

实际上我没有任何自定义单元格。 – ucb

+0

好吧,只需用你的标签访问它,最后让cell = tableView.dequeueReusableCell(withIdentifier:“cartcel”,for:indexPath)as!的UITableViewCell –

+0

FUNC的tableView(的tableView:UITableView的,的cellForRowAtIndexPath indexPath:NSIndexPath) - >的UITableViewCell { 让细胞= tableView.dequeueReusableCellWithIdentifier( “Songcell”,forIndexPath:indexPath) 让事件名称:的UILabel =(cell.viewWithTag(7)! UILabel) eventname.text = songnamearray.objectAtIndex(indexPath.row)as?字符串 恢复单元 } 这里是答案迅速2.0和7.3的Xcode对不起 –

2

您需要返回小区,因为是的cellForRowAtIndexPath非void函数:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { 

    let cell = super.tableView(tableView, cellForRowAtIndexPath: indexPath) 

    return cell 
} 
+1

谢谢回答,但我有一个恢复单元。 – ucb