2
出于某种原因,我的UITableViewCell显示字体的混合。下面是截图,演示了我的意思: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?
它总是相同的字符?即4和9的? – lnafziger 2012-03-21 21:22:54
哦,天啊!而已。字体不完整。它有0,1,2和3的字形,但没有更多。 Arrrggghhhh!感谢您指出明显。 – Axeva 2012-03-21 21:38:10