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