UITableView照片从Graph API显示多次

时间:2012-05-29 20:29:55

标签: ios facebook-graph-api uitableview sdwebimage

目前我正在为iPad制作Facebook应用程序。我拉墙并将其放入UITableView。我将照片放入tableview的方式是这样的:

在requestDidLoad中查询图像数组。

-(void)request:(FBRequest *)request didLoad:(id)result {

 //Determine if result is a array of images
if ([result objectForKey:@"images"] != nil) {
    if ([request.url rangeOfString: @"=images"].location != NSNotFound) {
         realPicsonWall = result;
        NSLog(@"Result Object: %@", [result objectForKey:@"images"]);


    }      
} 

然后在cellForRowAtIndexPath:

  UITableViewCell *cell = [tableView 
                         dequeueReusableCellWithIdentifier:@"messageCell"];
imageCellData *imageCell = [tableView dequeueReusableCellWithIdentifier:@"imageCell"];
//imageCellData is custom cell.
if ([[objectTypes objectAtIndex:indexPath.row] isEqualToString:@"photo"]) {
    //this is a picture


     NSArray *imagesArray = [realPicsonWall objectForKey:@"images"];
    NSDictionary *imageProps = [imagesArray objectAtIndex:3];

    NSLog(@"imageprops source: %@", [imageProps objectForKey:@"source"]);
    [imageCell.imageview setImageWithURL:[NSURL URLWithString:[imageProps objectForKey:@"source"]]];


    [imageCell layoutSubviews];
    return imageCell;


}else if ([[objectTypes objectAtIndex:indexPath.row] isEqualToString:@"video"]) {
    //this is a video
    NSLog(@"Video Called");
     NSDictionary *fromDictionary = [globalWhoPosted objectAtIndex:indexPath.row];
    cell.textLabel.text = @"Videos Are Not Supported";
     cell.detailTextLabel.text = [NSString stringWithFormat:@"Video Posted By: %@", [fromDictionary objectForKey:@"name"]];
    NSLog(@"Video By: %@", [fromDictionary objectForKey:@"name"]);
    return cell;
} 
else {
    NSDictionary *fromDictionary = [globalWhoPosted objectAtIndex:indexPath.row];
    NSString *story = [messages objectAtIndex:indexPath.row];
    cell.textLabel.text = story;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"By: %@", [fromDictionary objectForKey:@"name"]];

    cell.alpha = 1;
    return cell;
}

return cell;
}

在numberOfRows中:

{
   return [messages count];
}

我带来的墙上有2个不同的图像,但它拉出了2张相同的图像,所以在tableview中我看到相同的图像2次,而它应该是2差异。图片。任何帮助都会非常慷慨。感谢。

1 个答案:

答案 0 :(得分:0)

你有一个graphapi网址的例子吗?我可能会做的是寻找具有相同尺寸的所有图像。这将导致假设如果json中有多个图像,而不是仅仅是不同的分辨率,如果你抓住具有相同分辨率的图像,那么你将保证抓住那些独特的图像。