Help with Gold Solution Font Size


#1

I’m having trouble with the gold solution and font size. I’ve gotten the font size to change but it’s changing it for the last row as well. Where it gets really strange is as soon as the app launches it’s right the first time but if i scroll the phone down the font changes to the same as the other rows. My code for the table cell is below.

[code]-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Check for a reusable cell first, use that if it exists
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @“UITableViewCell”];

// If there is no reusable cell of this type, create a new one
if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @"UITableViewCell"];
}

// Set the text on the cell with the description of the item
// that is at the nth index of items, where n = row this cell
// will appear in on the tableview
if ([indexPath section] == 0) {
    if ([indexPath row] == [cheapItems count]) {
        [[cell textLabel] setText: @"No more items"];
    } else {
        BNRItem *p = [cheapItems objectAtIndex: [indexPath row]];
        [[cell textLabel] setFont: [UIFont systemFontOfSize: 20]];
        [[cell textLabel] setText: [p description]];
    }
} else {
    if ([indexPath row] == [expensiveItems count]) {
        [[cell textLabel] setText: @"No more items"];
    } else {
        BNRItem *p = [expensiveItems objectAtIndex: [indexPath row]];
        [[cell textLabel] setFont: [UIFont systemFontOfSize: 20]];            
        [[cell textLabel] setText: [p description]];
    }
}

return cell;

}[/code]


#2

Hi !
As you use reusable cells, you have to reset the font.

Regards,
Willem


#3

I had the same problem so I overwrite the font every time.

 else if ([_item valueInDollars] < 50) {
            [[cell textLabel]setFont:[UIFont systemFontOfSize:20]];
            [[cell textLabel]setText:[_item description]];
            return cell;
        }

#4

I had the same problem.

I used: