最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】用swift实现不允许用户点击某个tableview的某行的cell

Swift crifan 5166浏览 0评论

【问题】

Xcoode 7.0的iOS 9.0,Swift 2.0中,

之前已经实现了,在4行点table中间插入一行,作为特殊的分割行:

【已解决】尝试用Swift给TableView的cell中间添加自定义的分割行

但是上面还是存在其他方面的不完美的:

多余的灰色的row作为分隔行,还是可以被点击到的:

tableview cell still didselectrowatindexpath

 

而实际上作为用户,是不应该让用户去点击到的。

所以再去想办法。

 

【解决过程】

1.搜:

swift tableview make cell not touchable

swift uitableview make cell not touchable

参考:

uitableview – Make certain area of UITableViewCell not selectable – Stack Overflow

去试试有没有:

cell.selectionStyle

有,试试:

cell.selectionStyle = UITableViewCellSelectionStyle.None

结果是:

的确是可以的:

虽然用户可以点击-》输出了debug信息

user can touch output log but no touch down

但是,用户是没发选择的,也没有点击按下去的那个效果。

【总结】

如果想要让某个UITableView的cell不可选择的话,那么可以设置selection的style为none:

cell.selectionStyle = UITableViewCellSelectionStyle.None

即可。

转载请注明:在路上 » 【已解决】用swift实现不允许用户点击某个tableview的某行的cell

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.157 seconds, using 22.09MB memory