Domanda

I have an expanding/contracting table view.My parent cells have a different style than the children cell (parent cells have bigger font, children cell has smaller font). When I expand parent to display children, and then I scroll down to view more children, once i scroll back up to contract the parent cell, the parent cell has now taken on the font size of the children cell. Im thinking it has to do something with the dequeing the resuseable cell. Here is the method I'm using to configure the cells:

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

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

// Configure the cell...

if ([self tableView:tableView canCollapseSection:indexPath.section])
{
    if (!indexPath.row)
    {
        // first row
        cell.textLabel.text = @"Expandable"; // only top row showing


    }
    else
    {
        // all other rows
        cell.textLabel.text = @"Some Detail";
        cell.textLabel.textColor=[UIColor blackColor];
        cell.textLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:10.0];
        cell.accessoryView = nil;

    }
}
else
{
    cell.accessoryView = nil;
    cell.textLabel.text = @"Normal Cell";

}

return cell;

}

È stato utile?

Soluzione

Set the font there also for parent cells:

    else
    {
        cell.accessoryView = nil;
        cell.textLabel.text = @"Normal Cell";
        cell.textLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:20.0];
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top