TableViewCell多选;

CheckBox;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
} NSString *seleCity = [[dataSourceArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
cell.textLabel.text = seleCity;
cell.textLabel.textAlignment = NSTextAlignmentLeft;
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.font = [UIFont systemFontOfSize:];
if ([selectCitysArray containsObject:indexPath]) {
cell.imageView.image = [UIImage imageNamed:@"checkbox_on_background.png"];
} else
{
cell.imageView.image = [UIImage imageNamed:@"checkbox_off_background.png"];
} UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleChecking:)];
[cell.imageView addGestureRecognizer:tap];
cell.imageView.userInteractionEnabled = YES; return cell;
} - (void) handleChecking:(UITapGestureRecognizer *)tapRecognizer {
CGPoint tapLocation = [tapRecognizer locationInView:self.tableView];
NSIndexPath *tappedIndexPath = [self.tableView indexPathForRowAtPoint:tapLocation]; if ([selectCitysArray containsObject:tappedIndexPath]) {
[selectCitysArray removeObject:tappedIndexPath];
}
else {
[selectCitysArray addObject:tappedIndexPath];
}
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:tappedIndexPath] withRowAnimation: UITableViewRowAnimationFade];
}

参考:http://stackoverflow.com/questions/3666629/how-to-add-checkboxes-to-uitableviewcell

UITableViewCell 添加 checkbox 多选的更多相关文章

  1. 通过编写串口助手工具学习MFC过程——(五)添加CheckBox复选框

    通过编写串口助手工具学习MFC过程 因为以前也做过几次MFC的编程,每次都是项目完成时,MFC基本操作清楚了,但是过好长时间不再接触MFC的项目,再次做MFC的项目时,又要从头开始熟悉.这次通过做一个 ...

  2. DevExpress GridControl使用教程:之 添加 checkbox 复选框

    添加一列,FieldName为"FLAG",将ColumnEdit设置为复选框样式. gridview1   =>optionsbehavior =>  editabl ...

  3. Dtree 添加 checkbox 复选框 可以默认选中

    一:目标 要实现用一个树形结构的展示数据,每个节点(除了根节点)前有一个checkbox,同时,点击父节点,则子节点全选或者全不选,当选中了全部子节点,父节点选中:如下图所示: 同时可以在创建的时候, ...

  4. C# dev gridcontrol中添加checkbox复选框

    文章来源 csdn weinierbian http://blog.csdn.net/weinierbian/article/details/6255402 添加一列,FieldName为 " ...

  5. lightswitch Grid 控件添加 CheckBox 多选

    ACTIVATING MULTI SELECTION WITH CHECKBOXES IN A LIGHTSWITCH GRID WITH A ONE-LINER 2013/04/02 · by pa ...

  6. js操作checkbox(复选框)的方法总结

    收集了一些用js代码操作checkbox复选框的代码,分享出来,供需要的朋友参考: <script> //复选框checkbox 处理方法 //搜集整理 www.jbxue.com fun ...

  7. wpf中为DataGrid添加checkbox支持多选全选

    项目中用到DataGrid, 需要在第一列添加checkbox, 可以多选.全选. 其中涉及的概念DataTemplate, DataGridCellStyle, DataGridCellContro ...

  8. Winform开发 如何为dataGridView 添加CheckBox列,并获取选中行

    //添加CheckBox列 DataGridViewCheckBoxColumn columncb = new DataGridViewCheckBoxColumn(); columncb.Heade ...

  9. 转 纯CSS设置Checkbox复选框控件的样式

    Checkbox复选框是一个可能每一个网站都在使用的HTML元素,但大多数人并不给它们设置样式,所以在绝大多数网站它们看起来是一样的.为什么不把你的网站中的Checkbox设置一个与众不同的样式,甚至 ...

随机推荐

  1. 计蒜客 A2232.程序设计:蒜厂年会-单调队列(双端队列(STL deque)实现)滑窗维护最小前缀和

    程序设计:蒜厂年会 问答问题反馈 只看题面 16.79% 1000ms 262144K   在蒜厂年会上有一个抽奖,在一个环形的桌子上,有 nn 个纸团,每个纸团上写一个数字,表示你可以获得多少蒜币. ...

  2. python的版本会导致IBus设置(中文输入法)出错

    最近在学习python,可是,发现我的输入法 IBus-pinyin ,不能用了, 现象: 发现 “首选输入法”,根本点击不进去IBus设置的窗口,想去设置输入法都不行, IBus设置的窗口: 原因是 ...

  3. 1.L 查询关键字 HEXLOC

    Take the compile listing for the program that has either OFFSET or LIST option selected. Use the OFF ...

  4. 用xib自定义UITableViewCell的注意事项——重用

    问题的提出: 有时候我们经常需要自定义tableView的cell,当cell里面的布局较为复杂时往往舍弃纯代码的方式而改用xib的方式进行自定义.当我们用纯代码的方式布局cell时,往往会在cell ...

  5. bzoj 2468: [中山市选2010]三核苷酸

    2468: [中山市选2010]三核苷酸 Description 三核苷酸是组成DNA序列的基本片段.具体来说,核苷酸一共有4种,分别用’A’,’G’,’C’,’T’来表示.而三核苷酸就是由3个核苷酸 ...

  6. [AGC019E]Shuffle and Swap

    [AGC019E]Shuffle and Swap 题目大意: 给出两个长度为\(n(n\le10000)\)的\(01\)串\(A_{1\sim n}\)和\(B_{1\sim n}\).两个串均有 ...

  7. [转]Spring MVC 4常用的那些注解

    Spring从2.5版本开始在编程中引入注解,用户可以使用@RequestMapping, @RequestParam, @ModelAttribute等等这样类似的注解.到目前为止,Spring的版 ...

  8. mysql 创建存储过程及测试sql

    --存储过程 CREATE PROCEDURE proc_batch_id( out batch_id bigint ) begin insert into generate_sync_batch ( ...

  9. 为什么fis没有freemarker的解决方案啊?_前端吧_百度贴吧

    为什么fis没有freemarker的解决方案啊?_前端吧_百度贴吧 fis-plus:适用于PHP+Smarty后端选型jello:适用于Java+Velocity后端选型goiz:适用于go+ma ...

  10. realloc 用法

    #include <stdio.h> #include <stdlib.h> #include <string> int main() { char * p_cha ...