2014-04-02 47 views
0

你好我想要的代碼波紋管,我不能讓我的圖像顯示PFQueryTableViewController解析。不加載圖像

- (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嗎?

問候

+0

第一個我認爲你應該修復你的格式文章。關於你的問題,你確定[object objctForKey:@「image」]是否返回PFFile? – HoanNguyen

+0

對不起格式。是的文件正在下載。我使用NSLog打印它們 – Camus

+0

不要執行'getDataInBackgroundWithBlock:'部分。 'image'屬性是一個佔位符,以防遠程圖像不可用。 –

回答

0

加載從Parse.com(使用PFImageView)一個形象,你只要做到這一點:

creature.file = (PFFile *)file; 
    [creature loadInBackground]; 
+0

如果我不執行cellForRowAtIndePath。它工作得很好;但是我想定製我的細胞。 – Camus

0

你確定屬性 「形象」 是一個文件?如果是這樣,試試這個:

PFFile *theImage = [object objectForKey:@"image"]; 
[theImage getDataInBackgroundWithBlock:^(NSData *data, NSError *error){ 
    NSData *imageFile = [theImage getData]; 
    cell.imageView.image = [UIImage imageWithData:imageFile]; 
}]; 
相關問題