0
我似乎无法弄清楚如何将不同颜色的文本添加到我的表格视图单元格的右侧。这是我添加的代码。为表格视图单元格添加正确的细节
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *informationTableIdentifier = @"InformationCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:informationTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:informationTableIdentifier];
}
[cell.textLabel setFont:[UIFont systemFontOfSize:15]];
[cell.textLabel setTextColor:[UIColor blackColor]];
if (indexPath.section == 0) {
cell.textLabel.text = [infoCellFirstSection objectAtIndex:indexPath.row];
}
if (indexPath.section == 1) {
if (indexPath.row == 3 || indexPath.row == 3) {
cell.detailTextLabel.text = @"@SykesHarvey";
[cell.detailTextLabel setTextColor:[UIColor colorWithRed:0.48 green:0.93 blue:0.25 alpha:1.0]];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:informationTableIdentifier];
}
cell.textLabel.text = [infoCellSecondSection objectAtIndex:indexPath.row];
}
if (indexPath.section == 2) {
if (indexPath.row == 2 || indexPath.row == 3) {
[cell.textLabel setFont:[UIFont systemFontOfSize:14]];
[cell.textLabel setTextColor:[UIColor grayColor]];
cell.textLabel.numberOfLines = 0;
cell.backgroundColor = [UIColor clearColor];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
cell.textLabel.text = [infoCellThirdSection objectAtIndex:indexPath.row];
}
if (indexPath.section == 3) {
cell.textLabel.text = [infoCellFourthSection objectAtIndex:indexPath.row];
}
if (indexPath.section == 4) {
cell.textLabel.text = [infoCellFifthSection objectAtIndex:indexPath.row];
}
return cell;
}
所有这一切都呈现为但我想它说@SykesHarvey在开发电池的右侧。请有人可以帮忙吗?
我不明白你在做什么:你的情况与问题,你在做你试图设置你正在做的电池一个全新的分配/初始化的detailsText后,对不对?请注意'cell.detailsText'应该是'nil',因为没有'detailsText'和'UITableViewCellStyleDefault' – Larme
你能详细解释一下吗?到底什么是你的问题? –