【发布时间】:2015-03-13 12:22:34
【问题描述】:
我有单元格的自定义类,我有 UItableView 显示单元格的元素,例如标签和图像,我也使用 parse.com 作为应用程序的后端,每当我刷新表格时,最后一个单元格将重复第一个单元格,所以我一直在寻找解决方案以防止重复单元格,这是我的 cellForRowAtIndexPath 代码。
提前感谢您的帮助。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var myCell:Cell = tableView.dequeueReusableCellWithIdentifier("myCell") as Cell
// Configure the cell...
myCell.label1.text = Array1[indexPath.row]
myCell.label2.text = Array2[indexPath.row]
myCell.label3.text = Array3[indexPath.row]
myCell.label4.text = Array4[indexPath.row]
myCell.postedImage.layer.cornerRadius = myCell.postedImage.frame.size.width / 2
myCell.postedImage.clipsToBounds = true
//get the image from parse
imagefiles[indexPath.row].getDataInBackgroundWithBlock{(imageData: NSData!, error:NSError!) -> Void in
if error == nil {
let image = UIImage(data: imageData)
myCell.postedImage.image = image
}
}
}
return myCell
}
【问题讨论】:
标签: ios uitableview swift parse-platform