【发布时间】:2015-02-22 03:27:12
【问题描述】:
谁能告诉我我错过了什么或做错了什么?
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 不是一个类型,除非你自己创建它...应该是 UITableViewCell
-
是的,我先尝试过,但遇到了同样的错误。不熟悉这让我感到困惑。
-
我有一个名为 'VoteTableViewCell' 的 tableviewcell 文件并将其放入,它消除了以前的错误,但现在返回单元格上有一个说不能转换为 'PFTableViewCell'
-
哦,我明白了。您正在使用自定义单元格。确保它是自定义 PFTableViewCell 而不是自定义 UITableViewCell,因为您的 cellForRowAtIndexPath 方法返回一个 PFTableViewCell。
-
只是让您知道,这不是导致您的错误的原因。错误是因为 tableViewCell 不是固有类型引起的......但很高兴你明白了......