UITableView照片从Graph API多次显示 [英] UITableView Photos Show Up Multiple Times from Graph API

查看:77
本文介绍了UITableView照片从Graph API多次显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我正在为iPad开发一个Facebook应用程序.我拉墙,并将其放入UITableView中.我将照片放入表格视图的方式是这样的:

Right now I am making a Facebook Application For iPad. I pulling the wall and putting it into a UITableView. The way I am putting photos into the tableview is like this:

在requestDidLoad中,用于查询图像数组.

In the requestDidLoad for querying for array of images.

-(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中:

Then in 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中:

In numberOfRows:

{
   return [messages count];
}

我要拉的墙上有2张不同的图像,但是它拉出了2张相同的图像,因此在表格视图中我看到同一张图像2次,而应该是2个差异.图片.任何帮助都将非常慷慨.谢谢.

There 2 different images in the wall I bring to pull, but It pulls 2 of the same images, so in the tableview I see the same image 2 times, while it is supposed to be 2 diff. images. Any help would very generous. Thanks.

推荐答案

您是否有这种情况的graphapi网址示例?我可能要做的是寻找具有相同尺寸的所有图像.然后,这将导致这样一个假设:如果在json中有多个图像,而不仅仅是不同的分辨率,那么如果您以相同的分辨率抓取图像,那么就可以保证抓取唯一的图像.

Do you have an example of a graphapi url for which this is the case? Probably what I would do is look for the all the images with the same dimensions. This would then lead to the assumption that if more than one image is in the json, rather than just different resolutions, if you grab those with the same resolutions, then you'll be guaranteed to grab those that are unique.

这篇关于UITableView照片从Graph API多次显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆