[英]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.