无法使用PFQueryTableViewController(Swift2)显示自定义单元格 [英] Can't display custom cell with PFQueryTableViewController (Swift2)
问题描述
在Swift 2 +中使用parse.com v1.4(安装了可可豆荚)
Using parse.com v1.4 (installed with cocoa pods) with Swift 2 +
我已经使用自定义单元格设置了PFQueryTableViewController(ParseUI).我相信一切都已顺利完成,但是即使我确实收到并可以打印(调试过)它,也无法从Parse.com上显示该单元格的值.
I've setup up my PFQueryTableViewController (ParseUI) with a custom cell. I believe everything is hooked up fine, however I can't get the cell to display the value from Parse.com even though I do receive it and can print it (I've debugged it).
我这样出队:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
let cellIdentifier = "Cell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! OrderTableViewCell
// Extract values from the PFObject to display in the table cell
if let pfObject = object {
// prints expected value, e.g. 1, 2, 3
print(pfObject["table"])
// shows "Label" which is my label's default text on the SB!!
let table = pfObject["table"] as? String
cell.lblTable.text = table
}
return cell
}
我的PFQueryTableViewController的其余部分似乎可以从Parse加载数据:
The rest of my PFQueryTableViewController which seems to load data OK from Parse:
我的自定义单元格OrderTableViewCell(带有一些标签IBActions):
My custom cell OrderTableViewCell (with some label IBActions):
SB设置:
结果:
如何获取标签以显示实际文本?我想念什么?由于我通过Parse UI获得的其他功能,我不想恢复为标准的UITableView.
How can I get the label to display the actual text? What am I missing? I don't want to revert back to standard UITableView due to the additional features I get with Parse UI.
推荐答案
发现它就像更改一样简单
turns out it was as simple as changing
let table = pfObject["table"] as? String
到
let table = String(pfObject["table"])
这篇关于无法使用PFQueryTableViewController(Swift2)显示自定义单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!