简体   繁体   English

使用未声明类型的tableViewCell Swift

[英]Use of undeclared type tableViewCell Swift

Can someone tell me what am I missing or doing wrong? 有人可以告诉我我在想什么或做错了什么吗?

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
}

The error occurs on the tableViewCell and i been on this for hours but cant figure out whats wrong. 该错误发生在tableViewCell上,我已经花了几个小时了,但无法弄清楚出了什么问题。

The error is caused by the fact that tableViewCell is neither an inherent type, nor a type that you've created. 该错误是由于tableViewCell既不是固有类型也不是您创建的类型引起的。 Instead of tableViewCell , you probably meant to use UITableViewCell , PFTableViewCell , or a custom class's cell. 代替tableViewCell ,您可能打算使用UITableViewCellPFTableViewCell或自定义类的单元格。 But from the error it seems as if tableViewCell has never been declared as a type. 但是从错误看来,好像tableViewCell从未被声明为类型。

From your comments underneath the question, it's clear that you are in fact using a custom cell named VoteTableViewCell . 从问题的注释中可以看出,实际上您正在使用名为VoteTableViewCell的自定义单元格。 Therefore you should initialize cell as a VoteTableViewCell ; 因此,您应该将cell初始化为VoteTableViewCell but make sure it's a custom PFTableViewCell and not a custom UITableViewCell since your cellForRowAtIndexPath method returns a PFTableViewCell . 但请确保它是自定义PFTableViewCell而不是自定义UITableViewCell因为您的cellForRowAtIndexPath方法返回了PFTableViewCell

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM