解析上传图片UItableview

时间:2014-09-20 20:45:32

标签: ios iphone xcode uitableview parse-platform

- (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;
}

2 个答案:

答案 0 :(得分:0)

您需要将已下载的图像分配给您忘记的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;
}

答案 1 :(得分:0)

将此代码写入UITableView cellForRowAtIndexPath方法......

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

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