UITableViewCellAccessoryCheckmark 在iOS 7中未显示

7

我在我的单元格中显示勾选标记附件的时候遇到了问题。当我使用其他类型的附件时,它可以正常工作,但是使用勾选标记附件时就不行。

在iOS 6中可以完美工作,但是在iOS 7上却不行。我错过了什么?

 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:EVENT_SELECTION_CELL_IDENTIFIER forIndexPath:indexPath];
    Event *event = [self.fetchedResultsController objectAtIndexPath:indexPath];
    cell.textLabel.text = event.name;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if ([event.current boolValue]) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    } else {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    return cell;
}

1
他们在iOS7中改变了默认设置。 :)当选中单元格时,它具有默认的背景颜色。在iOS 7中,选择颜色不再是蓝色。请改用UITableViewCellSelectionStyleDefaultfloat version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version >= 7.0) { cell.selectionStyle = UITableViewCellSelectionStyleDefault; } else{ cell.selectionStyle = UITableViewCellSelectionStyleNone; } - Pradeep Mahdevu
我有同样的问题。请看我的问题链接:https://dev59.com/RHfZa4cB1Zd3GeqPVLz2#19418537 - audience
4个回答

23

我通过修改uitableview的色调颜色来解决了这个问题。

我通过InterfaceBuilder将uitable的tintcolor更改为默认颜色。

或者

TableView.tintColor =  [UIColor blackColor];

3

如果这对某些人有所帮助... 对我来说,设置tableview的色调颜色没有起作用,但是在cellForRowAtIndexPath中设置单元格色调颜色确实起作用:

cell.tintColor = [UIColor grayColor];

2
要恢复蓝色勾号标记(类似于iOS6),您可以使用以下方法:
cell.tintColor = [UIColor colorWithRed:(0.0/255.0) green:(122.0/255.0) blue:(255.0/255.0) alpha:1.0];

0

仅作为现实检查,因为您的代码似乎没问题,您能否将[event.current boolValue]更改为YES,似乎问题实际上在于该值... 我还将检查tableview的委托...

如果不是这个或那个,请告诉我们...我会删除这个答案...

if (YES) {
//..
}

我已经尝试过类似的事情,但那并没有改变任何东西。当我使用另一种附件类型时,它可以工作。 - wvp

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接