Сейчас я делаю приложение для Facebook для iPad. Я тяну стену и помещаю ее в UITableView. То, как я помещаю фотографии в таблицу, выглядит так:UITableView Фотографии показывают несколько раз из графика API
В 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 одинаковых изображений, так в представлении таблицы я вижу одно и то же изображение 2 раза, в то время как он должен быть 2 diff. изображений. Любая помощь была бы очень щедрой. Благодарю.
Можете ли вы опубликовать метод WHOLE cellForRowAtIndexPath? Где определены и назначены типы объектов? –
@obuseme опубликовано все «cellForRowAtIndexPath» – virindh