【问题标题】:Unable to dequeue a cell with identifier (error with Accessibility Identifier)无法将具有标识符的单元格出列(辅助功能标识符错误)
【发布时间】:2015-08-21 16:56:07
【问题描述】:

我一直在努力

无法将标识符为 TransactionCell 的单元格出列 - 必须为标识符注册一个 nib 或一个类,或连接情节提要中的原型单元格

但我不明白为什么。我在情节提要中设置了一个标识符(无法上传屏幕截图 - 没有足够的声誉)。

这是我的实际代码

  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = self.tableView.dequeueReusableCellWithIdentifier("TransactionCell", forIndexPath: indexPath) as TransactionCell


    var transaction: Transaction

    transaction = Manager.sharedManager.transactions[indexPath.row]

    var dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd"

    var myAmount = String(transaction.amount)
    cell.amountLabel?.text = myAmount
    cell.dateLabel?.text = dateFormatter.stringFromDate(transaction.date)
    cell.descriptionLabel?.text = transaction.description

    return cell
}

【问题讨论】:

标签: uitableview swift identifier


【解决方案1】:

我在故事板中设置了一个标识符

也许吧。但是:

  • 该标识符不是TransactionCell。或者:

  • 你把它放在错误的地方 - 它不是一个单元格标识符。或者:

  • 您忘记将情节提要中该场景中的表视图控制器的类设置为您的代码所在的表视图控制器的类。

【讨论】:

    【解决方案2】:

    我的问题是我在身份检查器中设置了可访问性标识符,而不是在属性检查器中... :doh:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-05
      • 2019-02-19
      • 1970-01-01
      • 1970-01-01
      • 2014-03-02
      • 2015-01-23
      • 1970-01-01
      相关资源
      最近更新 更多