选择UITableView中的所有单元格 [英] Select all the cells in UITableView

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

问题描述

当用户按下工具栏中的按钮时,选择表格中的所有单元格(UITableView)的最佳方法是什么?

what would be the best method to select all the cells in the table(UITableView) when the user presses a button in the tool bar?

推荐答案

您可以选择一个单元格调用表视图的selectRowAtIndexPath方法:

You can select a cell calling table view's selectRowAtIndexPath method:

[menuTable selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];

但是你不能在UITableView中选择多个单元格。
如果要显示和处理单元格的开/关状态,则应使用具有UITableViewCellAccessoryCheckmark类型的附件视图的单元格。 (有关详细信息,请参阅文档)

However you can't select multiple cells in a UITableView. If you want to show and process on/off state of cells you should use cell with accessory view with UITableViewCellAccessoryCheckmark type. (see docs for more details)

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

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