Imagens baixadas de forma assíncrona só aparecem no UITableView após tocar ou rolar
Estou carregando com êxito imagens em miniatura de postagens de blog de maneira assíncrona no meu UITableView.
O problema que estou tendo é que as imagens só aparecem se eu tocar na célula ou se eu rolar para baixo.
Quando eu toco na célula, a imagem aparece à esquerda, empurrando o título e a legenda para a direita.
Quando eu rolar para baixo, as imagens aparecem onde deveriam nas células à medida que são reveladas.
Aqui está o meu código (estou usando o AFNetworking):
#import "UIImageView+AFNetworking.h"
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return posts.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *post = [posts objectAtIndex:indexPath.row];
NSString *postpictureUrl = [post objectForKey:@"picture"];
[cell.imageView setImageWithURL:[NSURL URLWithString:postpictureUrl]];
cell.textLabel.text = [post objectForKey:@"post_text"];
cell.detailTextLabel.text = [post objectForKey:@"post_author_name"];
return cell;
}
Estou vendo isso no simulador do iPhone 6.0, XCode 4.5, OSX MtLion.
Alguma idéia por que as imagens não são desenhadas na tela inicial?