UITableView issue (iOS)

Posted by Oktay on Stack Overflow See other posts from Stack Overflow or by Oktay
Published on 2012-07-04T08:59:23Z Indexed on 2012/07/04 9:16 UTC
Read the original article Hit count: 178

Filed under:
|
|

I wonder why cellForRowAtIndexPath function is called when scrolling the UITableView. Does it mean on every scrolling cell configuration code runs again? I have a slowness problem when scrolling the table.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CountryCell";


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...
NSString *continent = [self tableView:tableView titleForHeaderInSection:indexPath.section];
NSString *country = [[self.countries valueForKey:continent] objectAtIndex:indexPath.row];

cell.textLabel.text = country;

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}

© Stack Overflow or respective owner

Related posts about ios

Related posts about uitableview