在我的 tableView 中,我在单元格之间设置了分隔线。我允许选择多个单元格。这是我设置选定单元格背景颜色的代码:
UIView *cellBackgroundColorView = [[UIView alloc] initWithFrame:cell.frame];
[cellBackgroundColorView setBackgroundColor:[UIColor darkGray]];
[cell setSelectedBackgroundView:cellBackgroundColorView];
问题是,如果选择了两个相邻的单元格,则在 iOS7 中它们之间没有分隔线,而在 iOS6 中则有(如预期的那样)。
我什至尝试设置cellBackgroundColorView
的框架高度为cell.frame - 1.0
,但这也行不通。
有任何想法吗?
我还没有弄清楚它的真相(乍一看这似乎是一个 iOS 7 的错误..),但我已经找到了一个解决方法。在 tableView:didSelectRowAtIndexPath 中,如果您发送下面两条消息,问题将在视觉上得到解决(可能会带来性能成本)。
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
为此(对我来说),deselectRowAtIndexPath:animated: 必须包含animated:YES。用于 reloadRowsAtIndexPaths:withRowAnimation: 的动画并不重要。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)