[英]Overriding UITableView in Parse with Swift
所有,
在使用Parse作为后端的过程中,我迅速创建了一个从PFQueryTableViewController继承的类。 我看到我的数据进入了表格视图-很好。
我试图稍微自定义单元格,然后覆盖CellForRowAtIndexPath-如下所示:
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell!
{
var cellIdentifier = "eventCell"
var cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) as? PFTableViewCell
if cell == nil {
cell = PFTableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: cellIdentifier)
}
// configure cell
var CellTitle = object.objectForKey("Title") as String
cell?.textLabel = CellTitle
}
}
随着使用的对象迅速以[AnyObject]的形式返回,我创建了一个变量并将其转换为字符串。 然后,我尝试在Cell.textlabel中显示该字符串。
我收到错误消息:无法分配该表达式的结果。 谁能告诉我正确的方向。
我认为问题是您正尝试直接将String
分配给cell?.textLabel
UILabel
。 而是尝试更改此行:
cell?.textLabel = CellTitle
对此
cell.textLabel?.text = CellTitle
因此,您改为设置UILabel
的text属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.