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:
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"]);
}
}
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;
}
In numberOfRows:
{
return [messages count];
}
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.