Estou carregando um tableView
a partir de um array
carregado de arrays
, todo esse processo de carregar está funcionado perfeitamente, no entanto, quando atualizo o tableView
(reloadData
) com as mesmas informações e estou com o scroll na metade da lista, por exemplo, os index's se perdem, isto é, quando acesso uma célula, ele carrega informação de outra. Por outro lado, se o Scroll está no topo da tableView
, mesmo atualizando, esse problema não ocorre. Segue código:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell_aux";
clsTableViewCell *cell = (clsTableViewCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"cell_aux" owner:self options:nil];
cell = (clsTableViewCell *)[nib objectAtIndex:0];
}
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
arInfos = [[NSArray alloc] initWithArray:[[arMain objectAtIndex:indexPath.row] componentsSeparatedByString:@"|"]];
[arInfosAll addObject:arInfos];
NSURL *imgURL = [NSURL URLWithString:[arInfos objectAtIndex:4]];
UIImage *Noimg=[UIImage imageNamed:@"NoImage.png"];
cell.img.image = Noimg;
cell.lblNome.text = [arInfos objectAtIndex:1];
cell.lblEndereco.text =[arInfos objectAtIndex:2];
NSURLRequest* request = [NSURLRequest requestWithURL:imgURL];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse * response,
NSData *imgData,
NSError * error)
{
if (!error)
{
UIImage *img = [UIImage imageWithData:imgData];
cell.img.image = img;
}
}];
}
return cell;
}
[arInfosAll addObject:arInfos];
? Mais uma dúvida, por que você não usa NSDictionary para cada indice de sua array ao invés de outra array?