tableViewに10行を追加しようとしていますが、forループでinsertRowsAtIndesPathsを使用してreloadData imの代わりに、一度に1行を追加する代わりに、最後に10行すべてを追加します。これが私のコードです...
if([[[[[notification userInfo] objectForKey:@"cityevent"]objectForKey:@"events"]objectForKey:@"event"] isKindOfClass:[NSArray class]])
{
[self.featuredEventTableView beginUpdates];
for(NSDictionary *tempDict in [[[[notification userInfo] objectForKey:@"cityevent"]objectForKey:@"events"]objectForKey:@"event"])
{
ESEvent *event=[[ESEvent alloc]init];
event.name=[tempDict objectForKey:@"name"];
if([[tempDict objectForKey:@"image"]isKindOfClass:[NSNull class]] || [tempDict objectForKey:@"image"] ==nil)
event.image=[UIImage imageNamed:@"category_default.png"];
else
{
event.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[tempDict objectForKey:@"image"]]]];
}
[events addObject:event];
NSIndexPath *ip=[NSIndexPath indexPathForRow:([events count]-1) inSection:0];
NSLog(@"row: %i section: %i",ip.row,ip.section);
[self.featuredEventTableView insertRowsAtIndexPaths:[NSArray arrayWithObject:ip] withRowAnimation:UITableViewRowAnimationRight];
[self.featuredEventTableView endUpdates];
}
}
助言がありますか?