2014-09-20 51 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; 
}