【问题标题】:Parse upload image UItableview [closed]解析上传图片 UItableview [关闭]
【发布时间】:2014-09-20 20:45:31
【问题描述】:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier =@"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;
}

【问题讨论】:

  • 这里要什么,请解释清楚。你想异步加载图片吗?
  • 是的。我的图像存储在 Parse.com
  • 那么你想在tableview中显示这些图像吗?
  • 是的。问题是我什么也看不见
  • 你使用了 'imagenArchivo',它返回的图片 url 是什么?

标签: ios iphone xcode uitableview parse-platform


【解决方案1】:

在您的 UITableView cellForRowAtIndexPath 方法中编写此代码 ...

PFFile *imageFile = [[yourArray objectAtIndex:indexPath.row] valueForKey:@"yourColumnName"];

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

【讨论】:

  • 为此使用 PFImageView
【解决方案2】:

您需要将下载的图像分配给您忘记的 Cell 的 UIImageView。我已将您的代码修改如下。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier =@"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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-25
    相关资源
    最近更新 更多