ios - 如何防止 UITableViewCell 在点击时被视觉取消选择?
问题描述
我使用以下设置我UITableViewCell
的 s 的选定背景颜色:
let backgroundColorView = UIView()
backgroundColorView.backgroundColor = .red
UITableViewCell.appearance().selectedBackgroundView = backgroundColorView
当我点击以选择它们时,单元格会短暂闪烁红色,然后返回到backgroundColor
我设置的位置。
当我添加:
if cell.isSelected
{
cell.backgroundColor = .red
}
到cellForRowAt indexPath
,当我将其滚动到视线之外并再次返回时,单元格会变为红色。
如何确保点击后单元格立即保持红色?
编辑:如果我将以下代码添加到cellForRowAt
,事情会按预期工作:
let backgroundColorView = UIView()
backgroundColorView.backgroundColor = .red
cell.selectedBackgroundView = backgroundColorView
可能是iOS错误?
解决方案
推荐阅读
- python-3.x - 如何将除法运算符 / 分配给文本单词“divided”或“divides”
- ruby - 带有标签的 rspec 过滤器 - 不要在 `describe` 中运行代码
- c++ - Netbeans C++ 项目上的 SFML 错误
- javascript - 是否可以为条件需要的对象数组编写自定义道具类型验证器而不会丢失对象验证?
- php - 如何将自定义文件添加到自定义文章列表页面
- javascript - Javascript添加/删除动画类,只动画一次
- javascript - 我是否需要知道 jquery 才能学习和处理 react js / angular js
- python - 如何在保持分辨率的同时无损地将 2D 浮点 numpy 数组保存到灰度图像中?
- javascript - 深入比较 javascript 对象并保留对象 1 的键和对象 2 的值
- java - 如何从当前登录的用户 Firebase,Android 中检索值