0

现在我正在为 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 差异。图片。任何帮助都会非常慷慨。谢谢。

4

1 回答 1

0

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

于 2012-05-30T01:16:05.510 回答