cell detailTextLable无法正确显示数字

时间:2012-07-18 17:48:00

标签: iphone uitableview nsdate nsdateformatter ios6

当我尝试将UITableView单元格中的日期显示为detailTextLable时,我得到的数字由附加的图片中的额外空格分隔,但是当我尝试NSLog时它显示正确(例如2012年7月19日)显示(如果使用附带的“yyyy-MM-dd”格式,则为7月1日9日,2 0 1 2)或(2 0 1 2 - 0 7 - 1 9)。 (图片下方的代码)

enter image description here

这是我的代码:

//Format the date
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//[dateFormat setDateFormat:@"yyyy-MM-dd"];

[dateFormat setDateStyle:NSDateFormatterMediumStyle];
/*NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormat setLocale:usLocale];*/

NSString *theDate = [dateFormat stringFromDate:[occasion date]];

//test
NSLog(@"The formatted date is:%@",theDate);


NSString *detailText = [NSString stringWithFormat:
                        @"%@",

                        theDate];
//test
NSLog(@"The detailed text is:%@", detailText);

[[cell detailTextLabel] setText:detailText];

1 个答案:

答案 0 :(得分:1)

您的代码看起来很好,这可能是一个字体问题,您是否更改了detailTextLabel字体? (它看起来像你做的,这不是默认字体......)