【发布时间】: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
}
【问题讨论】:
-
Interface Builder 中肯定有一些设置不正确。确保您的表视图内容设置为“动态原型”。在此处查看一些解决方案:stackoverflow.com/questions/19084274/…
标签: uitableview swift identifier