你如何防止 UITableViewCellSelectionStyleNone 从删除单元格分隔符 [英] How do you prevent UITableViewCellSelectionStyleNone from removing cell separator

查看:32
本文介绍了你如何防止 UITableViewCellSelectionStyleNone 从删除单元格分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以阻止 UITableViewCellSelectionStyleNone 移除单元格分隔符?

Is it possible to prevent UITableViewCellSelectionStyleNone from removing a cell separator?

我有一个自定义的可扩展 UITableViewCell,当我点击一个单元格时会发生这种情况:

I have a custom expandable UITableViewCell and this is what happens when I click a cell:

如果仔细观察,King's Meadow 和大学东入口之间没有分隔线.

If you look closely, there is no separator between King's Meadow and University East Entrance.

当我使用它时,它实际上使分隔符可见,但行分隔符显示的时间有延迟:

When I use this, it actually makes the separator visible, but there's a delay as to when the line separator shows:

(void)layoutSubviews {
    [super layoutSubviews];

    for (UIView *subview in self.contentView.superview.subviews) {
        if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
            subview.hidden = NO;
        }
    }
}

有没有更好的方法来解决这个问题?

Is there a better approach for this?

推荐答案

这解决了我的问题:

didSelectRowAtIndexPath 方法中,我使用了以下内容:

In the didSelectRowAtIndexPath method, I used the following:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

}

像魔术一样工作!

这篇关于你如何防止 UITableViewCellSelectionStyleNone 从删除单元格分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆