I'm loading a tableView
from a array
loaded with arrays
, this whole load process is working perfectly, however, when I update tableView
( reloadData
) with the same information and I have the scroll in the middle of the list, for example, the index's get lost, that is, when I access a cell, it loads information from another. On the other hand, if Scroll is at the top of tableView
, even updating, this problem does not occur. Here is the code:
- (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;
}