出于某种原因,我的UITableViewCell显示了混合字体。这是一个截图,演示了我的意思:
请注意,每行中的最后一个数字是错误的字体。根据我的测试,它有点随机,哪个角色搞砸了,所以不要让这个截图中的最后一个角色让你失望。
这是我设置字体的代码:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *iv;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[[cell textLabel] setFont: [UIFont fontWithName:@"BangBang" size: 36.0]];
[[cell detailTextLabel] setFont: [UIFont fontWithName:@"BangBang" size: 32.0]];
iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"woodTableRow~ipad.png"]];
} else {
[[cell textLabel] setFont: [UIFont fontWithName:@"BangBang" size: 22.0]];
[[cell detailTextLabel] setFont: [UIFont fontWithName:@"BangBang" size: 22.0]];
iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"woodTableRow.png"]];
}
[cell setBackgroundView: iv];
[iv release];
cell.textLabel.textColor = [UIColor blackColor];
[[cell textLabel] setShadowColor: [UIColor whiteColor]];
[[cell textLabel] setShadowOffset: CGSizeMake(0, 1)];
[[cell textLabel] setBackgroundColor: [UIColor clearColor]];
cell.detailTextLabel.textColor = [UIColor blackColor];
[[cell detailTextLabel] setShadowColor: [UIColor whiteColor]];
[[cell detailTextLabel] setShadowOffset: CGSizeMake(0, 1)];
[[cell detailTextLabel] setBackgroundColor: [UIColor clearColor]];
switch (indexPath.row) {
case ScoreRow:
[[cell textLabel] setText: @"Score"];
[[cell detailTextLabel] setText: @"1,234"];
break;
case TimeRow:
[[cell textLabel] setText: @"Time"];
[[cell detailTextLabel] setText: @"0:39"];
break;
default:
[[cell textLabel] setText: @""];
[[cell detailTextLabel] setText: @""];
break;
}
}
这对我没有意义。有人可以帮忙吗?
更新
我应该注意到我已经看过这两个StackOverFlow问题,但都没有帮助:
UITableViewCell Font Not Changing
What is -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] for?
答案 0 :(得分:2)
代码看起来很好,所以我怀疑它是一个不完整的字体实现。