【发布时间】:2009-12-13 02:57:37
【问题描述】:
我正在尝试使用以下代码自定义 UITableViewCell 的字体,以便在填充 tableview 时使用。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
}
// Set up the cell
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
NSString *temp = [[NSString alloc] initWithString:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]];
cell.textLabel.text = temp;
[[cell textLabel] setTextColor:[UIColor colorWithRed:154.0/255.0 green:14.0/255.0 blue:2.0/255.0 alpha:1]];
[[cell textLabel] setFont:[UIFont systemFontOfSize:12.0]];
return cell;
}
对于我的生活,我不知道为什么它不会改变字体!如果我在单元格文本中硬编码,例如cell.textLabel.text = @"TEST";
有什么建议吗?谢谢!
【问题讨论】:
标签: iphone uitableview