0

嗨,我正在尝试下面的代码,但我无法显示我的图像

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
{
     static NSString *CellIdentifier = @"Cell";

     PFTableViewCell *cell = (PFTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
     cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
     }

     // Configure the cell
     cell.textLabel.text = [object objectForKey:@"venueName"];
     cell.imageView.file = [object objectForKey:@"image"];
    [cell.imageView.file getDataInBackgroundWithBlock:^(NSData *data, NSError *error){
        cell.imageView.image = [UIImage imageWithData:data];
    }];

     return cell;
 }

我也尝试:

[cell.imageView loadInBackground];

没事了。我需要在单元格中手动插入 UIImage 吗?

问候

4

2 回答 2

0

要从 Parse.com 加载图像(使用 PFImageView),您只需执行以下操作:

   creature.file = (PFFile *)file;
   [creature loadInBackground];
于 2014-04-02T01:46:15.297 回答
0

你确定属性“图像”是一个文件吗?如果是,试试这个:

PFFile *theImage = [object objectForKey:@"image"];
[theImage getDataInBackgroundWithBlock:^(NSData *data, NSError *error){
    NSData *imageFile = [theImage getData];
    cell.imageView.image = [UIImage imageWithData:imageFile];
}];
于 2014-04-02T06:08:36.060 回答