如何禁用UITableView选择突出显示? [英] How can I disable the UITableView selection highlighting?

查看:144
本文介绍了如何禁用UITableView选择突出显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您点击 UITableView 中的行时,该行会突出显示并选中。

When you tap a row in a UITableView, the row is highlighted and selected. Is it possible to disable this so tapping a row does nothing?

推荐答案

所有你需要做的是将选择样式设置为 UITableViewCell 实例使用:

All you have to do is set the selection style on the UITableViewCell instance using either:

Objective-C:

Objective-C:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

Swift 2:

cell.selectionStyle = UITableViewCellSelectionStyle.None

Swift 3:

cell.selectionStyle = .none


$ b b

此外,请确保您不在表视图委托中实现 -tableView:didSelectRowAtIndexPath:,或明确排除您希望无操作的单元格请执行它。

Further, make sure you either don't implement -tableView:didSelectRowAtIndexPath: in your table view delegate or explicitly exclude the cells you want to have no action if you do implement it.

更多信息此处

这篇关于如何禁用UITableView选择突出显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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