1
我正在開發新聞提要,我正在使用uitableview來顯示數據。我synchronically加載在其他線程及使用協議的方法,每個單元中的數據,以顯示加載的數據:重複單元格,同時滾動uitableview
func nodeLoaded(node: NSMutableDictionary) {
for var i = 0; i < nodesArray.count; ++i {
if ((nodesArray[i]["id"] as! Int) == (node["id"] as! Int)) {
nodesArray[i] = node
}
}
}
的問題是,當我滾動我的UITableView(而數據synchronically裝載),我的一些細胞的重複(8行具有與第一行相同的內容,或者第六行具有與第二行相同的內容)。當我滾動一段時間後(我想在數據加載後),然後一切都變得正常。 我尋找答案,發現我要檢查,如果電池是nill在的cellForRowAtIndexPath,但在迅疾我的代碼是不同的,那麼在客觀C:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: NewsCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! NewsCell
var node = nodesArray[indexPath.row] as! NSDictionary
if (node["needLoad"] as! Bool) {
dbHelper.getNode(node["id"] as! Int, hash: node["id"] as! Int, tableName: DbHelper.newsTableName, callback: self)
} else {
cell.id = node["id"] as! Int
cell.titleLabel.text = node["title"] as? String
cell.descriptionLabel.text = node["description"] as? String
cell.imgView.image = WorkWithImage.loadImageFromSD((node["image"] as! String))
}
return cell
}
我也不能檢查,如果細胞==零BCS的二進制錯誤(NewsCell不能爲零)。
我該怎麼辦?謝謝。