구문 분석에서 유래 한 후 Ui를 수용하기 위해 TableViewData 소스 메서드를 호출하려고합니다. 이것으로 나는 이미지를 표시하려고 loaditem에 그런 다음이메서드 완료 후 TableViewDataSource로드하기
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
}
같이있는 tableview에이 가져온 데이터를 채울 수
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()
하지만하지를 가져올 수 있어요 그리고 난 내 자신을 writen있다 배열을 이미지 배열 채울 수 있지만 채울 때 제로 값 geeting 그래서 그것을 설정할 수 없습니다.
어떤 도움을 많이 주시면 감사하겠습니다!
컨트롤러에 tableview의 대리자/데이터 소스를 연결 했습니까? 즉, self.tableview.delegate = self; self.tableview.datasource = 자기; ? – Suresh
죄송합니다.하지만 실제로 나는 초보자로서 m을 얻는 데 아벨이 아니므로 안심하고 받으실 수 없으므로 이것에 관해 더 자세한 정보를 제공해주십시오. – user3519641
이 링크를 보시오. https://gist.github.com/watert/13c38d269ea15aa8360f – Suresh