你能帮帮我吗?我需要编辑单元格。编辑应该看起来像这样:当我按下一个barButtonItem (导航栏上右边的那个)时,单元格的内容应该稍微向右移动,并且应该会出现复选框。用户应该能够选择多个单元格,并通过单击相同的navButton来提交编辑。我尝试使用标准编辑,但我不知道如何使用:-选择多个单元格,然后才提交编辑-如何将提交操作设置为navButton,而不是显示在每个选定单元格旁边的红色删除按钮
发布于 2012-04-25 21:07:02
多选被认为是一种编辑风格。因此,要使单元格可多选,请在UITableViewDelegate中实现以下内容:
-(UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath {
...
return 3;
}这里的"3“表示多选。结果如下所示:

若要获取选定的行,请调用
-indexPathsForSelectedRows method on the table view.
NSArray* selectedRows = [tableView indexPathsForSelectedRows];如果不喜欢红色复选标记,可以使用未记录的multiselectCheckmarkColor属性对其进行更改。不幸的是,它必须应用于整个表。
tableView.multiselectCheckmarkColor = [UIColor blueColor];除非子类化或分类,否则不能更改浅蓝色背景颜色
UITableViewCell and override the -_multiselectBackgroundColor method, like this:
-(UIColor*)_multiselectBackgroundColor { return [UIColor yellowColor]; }希望,这会帮助你..
发布于 2013-01-19 23:34:31
Nit的答案有一个bug。
代码
tableView.multiselectCheckmarkColor = [UIColor blueColor];应该这样写:
[tableView setValue:[UIColor blueColor] forKey:@"multiselectCheckmarkColor"];我在Xcode4.5上试过了,它起作用了。
发布于 2014-07-06 21:32:04
如果它仍然相关,请注意,在iOS 7+上,您可以简单地使用UITableView的tintColor属性-这将设置复选标记颜色。
https://stackoverflow.com/questions/10316147
复制相似问题