2014-09-20 77 views
-4
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier [email protected]"imageCell"; 
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    NSData *imageData =UIImagePNGRepresentation([UIImage imageNamed:@"inbox.png"]); 
    PFObject *almacen = [_browserImagenes objectAtIndex:indexPath.row]; 
    PFFile *archivo = almacen [@"image"]; 
    [archivo getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { 
     if (!error) { 
      UIImage *image = [UIImage imageWithData:imageData]; 
     } 
    }]; 


    return cell; 
} 
+0

這裏你想要什麼,請解釋清楚。你想要異步加載圖像嗎? – 2014-09-20 21:55:20

+0

是的。我的圖像存儲在Parse.com – 2014-09-20 22:03:01

+0

所以你想要在tableview中顯示這些圖像? – 2014-09-20 22:05:27

回答

0

寫這樣的代碼在你的UITableView的cellForRowAtIndexPath方法...

PFFile *鏡像文件= [[yourArray objectAtIndex:indexPath.row] valueForKey:@ 「yourColumnName」];

if (imageFile) { 
    self.imageView.file = imageFile; 
    [self.imageView loadInBackground:^(UIImage *image, NSError *error) { 
    }]; 
} 
+0

爲此使用PFImageView – 2014-10-03 10:42:47

0

您需要將下載的圖像分配給您忘記的單元格的UIImageView。我已經修改你的代碼如下。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier [email protected]"imageCell"; 
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    NSData *imageData =UIImagePNGRepresentation([UIImage imageNamed:@"inbox.png"]); 
    PFObject *almacen = [_browserImagenes objectAtIndex:indexPath.row]; 
    PFFile *archivo = almacen [@"image"]; 
    [archivo getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { 
     if (!error) { 
      UIImage *image = [UIImage imageWithData:imageData]; 
      // *** Here you need to set image to imageview to display it *** 
      cell.imageView.image = image; 
     } 
    }]; 


    return cell; 
}