TabelView的多选模式
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) NSMutableArray *dataSourceArray;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.dataSourceArray = [NSMutableArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", nil];
UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
tableView.delegate= self;
tableView.dataSource = self;
//打开编辑状态
[tableView setEditing:YES animated:YES];
[self.view addSubview:tableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataSourceArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = self.dataSourceArray[indexPath.row];
return cell;
}
//这两个参数 一个一个写就是各自的状态,两个一起写 就成了前面的有圆圈的多选状态
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
}
//点击cell选择 往你数据源数组里面加东西
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
//这个是取消点击的cell 删除你数据源的东西
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
}
//根据上面的两个方法 删除你的cell和你的数据源的东西 记得刷新表
实现的效果
TabelView的多选模式的更多相关文章
- 解决jquery-easyui1.3.3 combobox 多选模式不兼容IE8问题
扩展Array的原型对象,加入indexOf方法 if(!Array.prototype.indexOf){ Array.prototype.indexOf = function(target) ...
- ListView多选操作模式详解CHOICE_MODE_MULTIPLE与CHOICE_MODE_MULTIPLE_MODAL
这篇文章我们将详细的介绍如何实现ListView的多选操作,文中将会纠正在使用ListViewCHOICE_MODE_MULTIPLE或者CHOICE_MODE_MULTIPLE_MODAL时容易犯的 ...
- ListView多选操作模式——上下文操作模式
1.什么叫上下文操作模式 2.如何进入上下文操作模式 1.ListView自身带了单选.多选模式,可通过listview.setChoiceMode来设置: listview.setChoiceMod ...
- ListView多选和单选模式重新整理
超简单的单选和多选ListView 在开发过程中,我们经常会使用ListView去呈现列表数据,比如商品列表,通话记录,联系人列表等等,在一些情况下,我们还需要去选择其中的一些列表数据进行编辑.以前, ...
- Xamarin 实现android gridview 多选
参考文章:http://blog.csdn.net/zhouyuanjing/article/details/8372686 GridView初始化代码: gridViewStudent = Find ...
- Android ListView(Selector 背景图片 全选 Checkbox等按钮)
list_item.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xm ...
- ListView 实现多选/单选
http://blog.csdn.net/ljfbest/article/details/40685327 ListView自身带了单选.多选模式,可通过listview.setChoiceMode来 ...
- ListView 实现多选/无线电
ListView本身与无线电.多选模式.由listview.setChoiceMode设置: listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE) ...
- ListView的操作模式的选择的更详细的解释CHOICE_MODE_MULTIPLE与CHOICE_MODE_MULTIPLE_MODAL
本文介绍了我们将如何取得具体ListView多选择操作.本文将正确使用ListViewCHOICE_MODE_MULTIPLE要么CHOICE_MODE_MULTIPLE_MODAL时间easy误区. ...
随机推荐
- CSS转载
原文地址:http://www.cnblogs.com/dolphinX/archive/2012/10/13/2722501.html 页面布局,或者是在页面上做些小效果的时候经常会用到 displ ...
- 利用新版ShareSDK进行手动分享(自定义分享界面)
之前有用过Share SDK进行快捷分享,可是官方demo中的快捷分享的界面已经设置死了,而公司的产品又设计了自己的分享界面,这就需要我进行手动分享了.当前ShareSDK版本是2.5.4. 看了一堆 ...
- 如何在程序中动态设置墙纸(使用IActiveDesktop接口)
大家都知道设置WINDOWS桌面墙纸的WIN32 API是SystemParametersInfo, 使用SPI_SETDESKWALLPAPER参数便能设置墙纸: ::SystemParameter ...
- QSqlDatabase的进一步封装(多线程支持+更加简单的操作)——同时支持MySQL, SQL Server和Sqlite
开发背景: 1.直接用QSqlDatabase我觉得太麻烦了: 2.对于某些数据库,多个线程同时使用一个QSqlDatabase的时候会崩溃: 3.这段时间没什么干货放出来觉得浑身不舒服,就想写一个. ...
- chroot 的用途
http://www.ibm.com/developerworks/cn/linux/l-cn-chroot/ http://liyongxian.blog.51cto.com/432519/1126 ...
- lucene3.6笔记添加搜索功能
lucene为程序添加搜索功能,此功能基于已创建好的文档的索引之上.这里我已经为一些文档建立了索引,并保存到硬盘上.下面开始针对这些索引,添加搜索功能. 1.简单的TermQuery搜索 Java代码 ...
- [Android]The connection to adb is down, and a severe error has occured.
在Android开发时,有时我们开启虚拟机执行程序时.会报类似下面错误: [2015-07-19 15:08:29 - TestXiaoYanLibrary] The connection to ad ...
- scanf函数和printf函数
C程序实现输出和输入的 主要是printf函数 和 scanf函数,这两个函数是格式输入输出 格式声明由%和格式字符组成 如%d,%f 格式字符: d格式符:用来输出一个有符号的十进制整数 c格式 ...
- vim vimrc
set nu set shiftwidth= set tabstop= set softtabstop= set autoindent set cindent set smartindent file ...
- Redis是什么
Redis是什么 Redis是什么,首先Redis官网上是这么说的:A persistent key-value database with built-in net interface writte ...