【发布时间】:2012-03-15 18:23:26
【问题描述】:
我有一个包含默认样式单元格的 UITableView。在 Xcode 4 IB 中,我无法更改单元格内 textLabel 的颜色。但是,我可以更改字体和大小、每个单元格的行数等。只是不能更改文本颜色。有趣的是,我也不能以编程方式做到这一点。
// Give the table view a cell to display for a single row
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// reuse or create the cell
static NSString *cellID = @"MyCustomCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
// NOTE: the setting below does not work when set either here or in IB.
cell.textLabel.textColor = [UIColor yellowColor];
// set the text for the cell
cell.textLabel.text = [appDelegate.sharedData.arrayFaves objectAtIndex:indexPath.row];
return cell;
}
【问题讨论】:
标签: ios uitableview