【发布时间】:2011-09-26 18:04:15
【问题描述】:
我有一个 UITableView,作为 cellForRowAtIndexPath 方法,我正在更改单元格的一些属性(字体、大小等)。现在,除了更改 textLabel 的颜色之外,下面列出的所有分配都可以正常工作。我不明白为什么只有那个特定的颜色属性不会改变。我到处寻找我能想到的地方,以找出为什么它不起作用并且我被卡住了。有任何想法吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *kLocationAttributeCellID = @"bAttributeCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kLocationAttributeCellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:kLocationAttributeCellID] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.detailTextLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0];
cell.detailTextLabel.numberOfLines = 0;
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.userInteractionEnabled = NO;
cell.textLabel.font = [UIFont fontWithName:@"Courier" size:18.0];
cell.textLabel.textColor = [UIColor redColor]; // this never takes effect...
}
cell.textLabel.text = @"Test Label";
cell.detailTextLabel.text = @"Test Details";
return cell;
}
【问题讨论】:
标签: ios uitableview