簡體   English   中英

使用未聲明類型的tableViewCell Swift

[英]Use of undeclared type tableViewCell Swift

有人可以告訴我我在想什么或做錯了什么嗎?

override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {

    let cell = tableView.dequeueReusableCellWithIdentifier("chatCell", forIndexPath: indexPath) as
      tableViewCell

    cell.chatText.text = object.valueForKey("chatText") as String
    cell.chatText.numberOfLines = 0
    let score = object.valueForKey("count") as Int
    cell.count.text = "\(score)"
    cell.time.text = "\((indexPath.row + 1) * 3)m ago"
    cell.replies.text = "\((indexPath.row + 1) * 1) replies"
    return cell
}

該錯誤發生在tableViewCell上,我已經花了幾個小時了,但無法弄清楚出了什么問題。

該錯誤是由於tableViewCell既不是固有類型也不是您創建的類型引起的。 代替tableViewCell ,您可能打算使用UITableViewCellPFTableViewCell或自定義類的單元格。 但是從錯誤看來,好像tableViewCell從未被聲明為類型。

從問題的注釋中可以看出,實際上您正在使用名為VoteTableViewCell的自定義單元格。 因此,您應該將cell初始化為VoteTableViewCell 但請確保它是自定義PFTableViewCell而不是自定義UITableViewCell因為您的cellForRowAtIndexPath方法返回了PFTableViewCell

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM