如何禁用UITableView选择? [英] How can I disable the UITableView selection?

查看:51
本文介绍了如何禁用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?

推荐答案

对我来说,以下方法工作正常:

For me, the following worked fine:

tableView.allowsSelection = false

这意味着 didSelectRowAt#根本不起作用。就是说,如此触摸桌子的一排,绝对没有任何作用。 (因此,显然,绝不会有选定的动画。)

This means didSelectRowAt# simply won't work. That is to say, touching a row of the table, as such, will do absolutely nothing. (And hence, obviously, there will never be a selected-animation.)

(请注意,如果在单元格上有 UIButton 或其他任何控件,当然这些控件仍然可以使用,您碰巧在表格单元格上拥有的任何控件与UITableView允许您使用<$ c $来选择行的能力完全无关c> didSelectRowAt#。)

(Note that if, on the cells, you have UIButton or any other controls, of course those controls will still work. Any controls you happen to have on the table cell, are totally unrelated to UITableView's ability to allow you to "select a row" using didSelectRowAt#.)

要注意的另一点是:当 UITableView 处于编辑模式。要在编辑模式下限制单元格的选择,请使用以下代码:

Another point to note is that: This doesn't work when the UITableView is in editing mode. To restrict cell selection in editing mode use the code as below:

tableView.allowsSelectionDuringEditing = false 

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

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