Objective c 多个复选标记附件在iOS7中工作不正常

Objective c 多个复选标记附件在iOS7中工作不正常,objective-c,xcode,uitableview,ios7,Objective C,Xcode,Uitableview,Ios7,我有一个UITableview,其中列出了用户可以选择过滤其他列表的选项。单击此tableview中的项目时,会显示复选标记,如果再次单击,复选标记将消失。允许用户单击多个tableview单元格,以同时在多个单元格上显示复选标记。tableview也分为多个部分 这一切都可以在iOS 8上正常工作,但当我在iOS 7上运行时,当我单击单元格时,复选标记不会显示出来。如果我转到另一个视图,然后返回到tableview,复选标记就在那里。我在stackoverflow上搜索了其他帖子,这些帖子建议

我有一个UITableview,其中列出了用户可以选择过滤其他列表的选项。单击此tableview中的项目时,会显示复选标记,如果再次单击,复选标记将消失。允许用户单击多个tableview单元格,以同时在多个单元格上显示复选标记。tableview也分为多个部分

这一切都可以在iOS 8上正常工作,但当我在iOS 7上运行时,当我单击单元格时,复选标记不会显示出来。如果我转到另一个视图,然后返回到tableview,复选标记就在那里。我在stackoverflow上搜索了其他帖子,这些帖子建议我应该尝试将单元格的色调设置为黑色,但我尝试了,但没有成功

我还用一个自定义单元格替换了复选标记,该单元格带有一个我取消隐藏和隐藏的复选标记图像。这里的复选标记在我单击它们时显示,但当我再次单击它们时,它不会消失。为了清楚起见,我将附上下面的代码

@property NSMutableArray *favorite;
@property NSMutableArray *favoriteCheckmark;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
FilterCell *cell = [tableView dequeueReusableCellWithIdentifier:@"filtercell" forIndexPath:indexPath];
switch (indexPath.section) {
    case 0:
        cell.textLabel.text = [favorite objectAtIndex:indexPath.row];
        if ([favoriteCheckmark containsObject:indexPath]){
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
        }else{
            cell.accessoryType = UITableViewCellAccessoryNone;
        }
        break;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
FilterCell *cell = [tableView dequeueReusableCellWithIdentifier:@"filtercell" forIndexPath:indexPath];
switch (indexPath.section) {
    case 0:
        cell.textLabel.text = [favorite objectAtIndex:indexPath.row];
        if ([favoriteCheckmark containsObject:indexPath]){
            [favoriteCheckmark removeObject:indexPath];
        }else{
            [favoriteCheckmark addObject:indexPath];
        }
        break;
    }
}

我不确定,但这可能与此有关:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
FilterCell *cell = [tableView dequeueReusableCellWithIdentifier:@"filtercell" forIndexPath:indexPath];
switch (indexPath.section) {
    case 0:
        cell.textLabel.text = [favorite objectAtIndex:indexPath.row];
        if ([favoriteCheckmark containsObject:indexPath]){
            [favoriteCheckmark removeObject:indexPath];
        }else{
            [favoriteCheckmark addObject:indexPath];
        }
        break;
    }
}
你的电话是:

FilterCell *cell = [tableView dequeueReusableCellWithIdentifier:@"filtercell" forIndexPath:indexPath];
在did Press上,正在查询一个新的单元格,可能会导致问题。试着去掉那条线,看看会发生什么


即使这不能解决您的问题,您也应该删除该行。它在当前位置没有任何用途。

另外,在didSelectRowAtIndexPath方法中,没有重载数据调用来更新UI以匹配新更新的模型。