Chr*_*ter 17 uitableview ios swift
当我点击表格视图的单元格时,它们变暗为灰色,并且在我点击不同的单元格之前不会变回白色.是否有某种布尔值我必须设置它不这样做?
这是一个解释我的问题的截图:
与其他网站的链接将有所帮助,如果它意味着更详细的描述.(除非它是一个超级简单的修复,否则正确的代码或步骤将比链接更容易.)
小智 38
这是UITableView的默认行为.
您必须deselectRowAtIndexPath在didSelectRowAtIndexPathUITableViewController类内部调用.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
查看iOS文档以获取更多信息.
UITableView
UITableViewDelegate
MBH*_*MBH 22
斯威夫特3
选项1 :(我总是使用)
要在使用灰色选择后淡出动画,您可以执行以下操作:
func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
选项2:
要完全删除高亮效果,您可以将此行添加到cellForRowAt:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = .....
cell.selectionStyle = .none
return cell
}
Run Code Online (Sandbox Code Playgroud)
Ant*_*ito 12
你可以通过几种方式做到这一点......
tableView.allowsSelection = false
您可以在xCode Storyboard中将tableView设置为在第四个选项卡下没有任何选择.
或者,您可以在单元格上执行此操作 cell.selectionStyle = UITableViewCellSelectionStyle.None
你想要的最终将是关于你正在追求什么样的行为.做一点实验.
| 归档时间: |
|
| 查看次数: |
11605 次 |
| 最近记录: |