UITableViewCell 添加 checkbox 多选
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 多选的更多相关文章
- 通过编写串口助手工具学习MFC过程——(五)添加CheckBox复选框
通过编写串口助手工具学习MFC过程 因为以前也做过几次MFC的编程,每次都是项目完成时,MFC基本操作清楚了,但是过好长时间不再接触MFC的项目,再次做MFC的项目时,又要从头开始熟悉.这次通过做一个 ...
- DevExpress GridControl使用教程:之 添加 checkbox 复选框
添加一列,FieldName为"FLAG",将ColumnEdit设置为复选框样式. gridview1 =>optionsbehavior => editabl ...
- Dtree 添加 checkbox 复选框 可以默认选中
一:目标 要实现用一个树形结构的展示数据,每个节点(除了根节点)前有一个checkbox,同时,点击父节点,则子节点全选或者全不选,当选中了全部子节点,父节点选中:如下图所示: 同时可以在创建的时候, ...
- C# dev gridcontrol中添加checkbox复选框
文章来源 csdn weinierbian http://blog.csdn.net/weinierbian/article/details/6255402 添加一列,FieldName为 " ...
- lightswitch Grid 控件添加 CheckBox 多选
ACTIVATING MULTI SELECTION WITH CHECKBOXES IN A LIGHTSWITCH GRID WITH A ONE-LINER 2013/04/02 · by pa ...
- js操作checkbox(复选框)的方法总结
收集了一些用js代码操作checkbox复选框的代码,分享出来,供需要的朋友参考: <script> //复选框checkbox 处理方法 //搜集整理 www.jbxue.com fun ...
- wpf中为DataGrid添加checkbox支持多选全选
项目中用到DataGrid, 需要在第一列添加checkbox, 可以多选.全选. 其中涉及的概念DataTemplate, DataGridCellStyle, DataGridCellContro ...
- Winform开发 如何为dataGridView 添加CheckBox列,并获取选中行
//添加CheckBox列 DataGridViewCheckBoxColumn columncb = new DataGridViewCheckBoxColumn(); columncb.Heade ...
- 转 纯CSS设置Checkbox复选框控件的样式
Checkbox复选框是一个可能每一个网站都在使用的HTML元素,但大多数人并不给它们设置样式,所以在绝大多数网站它们看起来是一样的.为什么不把你的网站中的Checkbox设置一个与众不同的样式,甚至 ...
随机推荐
- win7家庭版如何获得管理员权限?
1.首先,打开你的命令提示符,输入cmd.有一点非常重要,如图所示,我们必须“以管理员的方式打开”.只有以管理员身份打开,那么接下来要敲打的命令才会成功. 2. 打开命令提示符后,在输入框输入net ...
- Codeforces Testing Round 14
A:The Way to Home link:http://codeforces.com/contest/910/problem/A 题面:有每次最大跳跃距离d,只有一部分的点可以落脚,求最少几步达到 ...
- 【多重背包】CDOJ1691 这是一道比CCCC简单题经典的中档题
#include<cstdio> #include<algorithm> using namespace std; int n,V,w[110],c[110],a[110],f ...
- 【深度搜索+剪枝】POJ2362-Square
从昨天晚上写到现在,一直在TLE,现在终于剪枝完成了_(:зゝ∠)_ [思路] 深搜:用这类型组合题目最基本的深搜,变量side记录当成已经组成了几条变,sl表示当前在组合的边已经有的长度.如果当前s ...
- (原创)Stanford Machine Learning (by Andrew NG) --- (week 3) Logistic Regression & Regularization
coursera上面Andrew NG的Machine learning课程地址为:https://www.coursera.org/course/ml 我曾经使用Logistic Regressio ...
- Windows下编译protobuf v3.3.0
一:概述 关于 protobuf 在此不再多说,此处记录下成功编译步骤以备日后查阅.注意:本文并不是使用cmake gui进行编译的,如果熟悉cmake gui的话,也可以使用gui进行生成编译. 二 ...
- 十一. 图形、图像与多媒体5.Graphics2D类的绘图方法
Java语言在Graphics类提供绘制各种基本的几何图形的基础上,扩展Graphics类提供一个Graphics2D类,它拥用更强大的二维图形处理能力,提供.坐标转换.颜色管理以及文字布局等更精确的 ...
- HDU 5631 Rikka with Graph 暴力 并查集
Rikka with Graph 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5631 Description As we know, Rikka ...
- fedora19/opensuse13.1 配置openvpn client
Date: 20140207Auth: Jin 1.install # yum -y install openvpn #zypper install openvpn 2.copy user key # ...
- The MinGW and mingw-w64 projects.----GCC
https://gcc.gnu.org/install/binaries.html Installing GCC We are often asked about pre-compiled versi ...