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