【发布时间】:2026-01-05 01:45:01
【问题描述】:
我想在从 parse 提取 Ui 后调用 TableViewData Sources 方法来查看 Ui。有了这个我可以获取
func loadImages() {
var query = PFQuery(className: "TestClass")
query.orderByDescending("objectId")
query.findObjectsInBackgroundWithBlock ({(objects:[AnyObject]!, error: NSError!) in
if(error == nil){
self.getImageData(objects as [PFObject])
}
else{
println("Error in retrieving \(error)")
}
})//findObjectsInBackgroundWithblock - end
}
func getImageData(objects: [PFObject]) {
for object in objects {
let thumbNail = object["image"] as PFFile
println(thumbNail)
thumbNail.getDataInBackgroundWithBlock({
(imageData: NSData!, error: NSError!) -> Void in
if (error == nil) {
var imageDic = NSMutableArray()
self.image1 = UIImage(data:imageData)
//image object implementation
self.imageResources.append(self.image1!)
println(self.image1)
println(self.imageResources.count)
}
}, progressBlock: {(percentDone: CInt )-> Void in
})//getDataInBackgroundWithBlock - end
}//for - end
self.tableView.reloadData()
但无法像这样将这些获取的数据填充到 tableview 中
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
println("in table view")
println(self.imageResources.count)
return imageResources.count+1;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:CustomTableViewCell = tableView.dequeueReusableCellWithIdentifier("customCell") as CustomTableViewCell
var (title, image) = items[indexPath.row]
cell.loadItem(title: title, image: image)
println("message : going upto this line")
println(self.imageResources.count)
var (image1) = imageResources[indexPath.row]
cell.loadItem1(image1: image1)
return cell
}
然后在 loaditem 上,我试图显示图像,并且我已经编写了自己的数组来填充图像数组,但是在填充时我得到一个零值,因此无法设置它
非常感谢任何帮助!
【问题讨论】:
-
您是否将tableview的委托/数据源与控制器连接起来。即,self.tableview.delegate = self; self.tableview.datasource = 自我; ?
-
对不起suresh,但实际上我不能让你像我一样是新手,所以无法得到它,你能提供更多关于这方面的信息吗?
-
尝试在 Parse 完成检索数据时调用
your_table_view.reloadData()。 -
@ios 我尝试调用我自己的 tableview 数据,但仍然是那个空的索引缓冲区
标签: ios swift parse-platform ios8