选择UITableViewCell选中标记更改 [英] UITableViewCell checkmark change on select

查看:133
本文介绍了选择UITableViewCell选中标记更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为将on的复选标记更改为off是正确的,我必须在 none之间更改 CellAccessoryType 选中标记 didSelectRowAtIndexPath

Am I correct in thinking that to change the checkmark for "on" to "off", I must change the CellAccessoryType between none and checkmark on the didSelectRowAtIndexPath?

因为我已经这样做但是我注意到行为与iphone上的自动锁定设置上的复选标记单元格完全相同。

Because I have done this but I have noticed the behaviour is not perfectly identical to like the checkmark cells on the auto lock settings on the iphone.

或者是否有一些其他方式是否需要处理复选标记?

Or is there some other way checkmarks are meant to be handled?

推荐答案


  1. 在您的视图中保留一个属性控制器名为 selectedRow ,它表示代表表格部分中已检查项目的行的索引。

  1. Keep a property in your view controller called selectedRow, which represents the index of a row that represents the checked item in a table section.

在视图控制器的 -tableView:cellForRowAtIndexPath:委托方法中,设置 accessoryType > cell to UITableViewCellAccessoryCheckmark 如果单元格的 indexPath.row 等于 selectedRow 价值。否则,将其设置为 UITableViewCellAccessoryNone

In your view controller's -tableView:cellForRowAtIndexPath: delegate method, set the accessoryType of the cell to UITableViewCellAccessoryCheckmark if the cell's indexPath.row equals the selectedRow value. Otherwise, set it to UITableViewCellAccessoryNone.

在视图控制器的 -tableView中:didSelectRowAtIndexPath:委托方法,将 selectedRow 值设置为 indexPath.row 即选中,例如: self.selectedRow = indexPath.row

In your view controller's -tableView:didSelectRowAtIndexPath: delegate method, set the selectedRow value to the indexPath.row that is selected, e.g.: self.selectedRow = indexPath.row

这篇关于选择UITableViewCell选中标记更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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