2016-01-13 32 views
-4

我對swift非常陌生,並且此錯誤不斷彈出。在函數錯誤中缺少返回值 - Swift Xcode

它說missing return in a function expected to return in UITableViewCell

代碼: My Code

任何幫助......感謝這麼多

+1

不要添加代碼的圖像,複製/粘貼到問題中。然後在工具欄的{}上選擇代碼和chicl,使其顯示爲代碼。 – zaph

回答

1

你需要聲明一個細胞。該標識符是您在Storyboard中添加的標識符,在本示例中,我的名稱是「Cell」。

let cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 

設置單元格屬性,例如

cell.textLabel.text = "Test" 

,然後返回電池

return cell 

這個方法返回給定路徑上的小區,所以這是部分是你爲單元添加信息。閱讀documentation熟悉UITableView類。

func tableView(tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ 
     let cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 
     cell.textLabel.text = "Test 
     return cell 
    } 
+0

我仍然困惑請幫助... –

+0

檢查更新的文本。 –