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误区. ...
随机推荐
- android 环境搭建 windows, linux
android环境也搭建了很多次了,linux下window下.在这里记录下,以后再搭建设置变量啥的就直接看自己的博客就好了.电子挡笔记有时候也不方便 1.下载材料 概述:用的是比较简单的方式搭建环境 ...
- 获取EIP(汇编语言直接给Delphi变量赋值)
var EIP: Cardinal; procedure GetEIP(); stdcall; asm pop eax; mov EIP,eax; push eax; end; procedure T ...
- [Leetcode][Python]31: Next Permutation
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 31: Next Permutationhttps://oj.leetcode ...
- c++链接数据库测试,中文有问题
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <Windows.h& ...
- Seinfeld(栈模拟)
Seinfeld Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- C++ *max_element函数找最大元素 *min_element函数找最小元素 STL算法(转)
http://blog.sina.com.cn/s/blog_6f3a860501019z1f.html #include<iostream> #include<algorithm& ...
- 统计分析SQL Server Profiler 跟踪的SQL
--跟踪文件读入到表中分析 SELECT * INTO ZGSJY FROM fn_trace_gettable('E:\wxxcdbprofiler.trc', default); --某时间内,最 ...
- DIR - matlab函数
DIR List directory. DIR directory_name lists the files in a directory. Pathnames and wildcards may b ...
- sql server varchar(10)和 nvarchar(10)存储数据长度
) 存储10个字母,英文标点符号等,5个汉字以及中文标点等. )存储10汉字.字母等,不区分中英文.
- tomcat最大线程数的设置(转)
1.Tomcat的server.xml中连接器设置如下 <Connector port="8080" maxThreads="150" minSpareT ...