tableView的编辑
首先记住声明编辑样式的属性 UITableViewCellEditingStyle 和四个步骤
第一步:让tableView处于编辑状态
[self.rootView.tabView setEditing:!self.rootView.tabView.editing animated:YES];
第二步:指定哪些cell可以被编辑。 默认是所有的cell都可以被编辑,(但是这个方法可以指定哪个分区可以被编辑)
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { return YES; }
第三步:设置编辑样式 (默认删除)
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return self.style; }
第四步:完成编辑, 提交编辑状态
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
ViewController.m
#import "RootViewController.h" #import "RootView.h" #define kColur arc4random() % 256 / 255.0 @interface RootViewController ()<UITableViewDataSource, UITableViewDelegate> @property (nonatomic, strong)RootView *rootView; // 声名大数组,用来存放所有的学生信息 @property (nonatomic, strong)NSMutableArray *AllDataArrray; // 声明编辑样式的属性 @property (nonatomic, assign)UITableViewCellEditingStyle style; @end @implementation RootViewController - (void)loadView { self.rootView = [[RootView alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.view = self.rootView; } - (void)viewDidLoad { [super viewDidLoad]; self.rootView.tabView.dataSource = self; self.rootView.tabView.delegate = self; // 设置数据 [self handleDate]; // 处理导航栏 self.title = @"管理"; self.navigationController.navigationBar.barTintColor = [UIColor orangeColor]; // 添加右按钮 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(click:)]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(leftClick:)]; } // 设置数据 - (void)handleDate { // 1.初始化大数组 self.AllDataArrray = [NSMutableArray array]; // 2.定义三个数组存放每一组学生的姓名 NSMutableArray *array1 = @[@"-1", @"ququ", @"网红", @"老司机", @"bobo", @"唱吧网红小尊"].mutableCopy; NSMutableArray *array2 = @[@"yida", @"mbBoy", @"lida", @"boomSky", @"正能量"].mutableCopy; NSMutableArray *array3 = @[@"py", @"她家傲然", @"MBBoy", @"tableView的编辑的更多相关文章
- ios之UITableViewController(二) tableView的编辑模式
tableView的编辑模式 表视图可以进入编辑模式,当进入编辑模式就可以进行删除.插入.移动单元等操作 效果图: 让表视图进入编辑模式,进入编辑模式的方法有两种,一种是使用导航栏的edit 按钮,另 ...
- iOS UIKit:TableView之编辑模式(3)
一般table view有编辑模式和正常模式,当table view进入编辑模式时,会在row的左边显示编辑和重排控件,如图 42所示的编辑模式时的控件布局:左边的editing control有表 ...
- 07-UIKit(tableview的编辑模式、accessoryView)
目录: 一.tableview的编辑模式-增删改查 二.不使用继承创建tableview 三.accessoryView辅助视图 回到顶部 一.tableview的编辑模式-增删改查 [1-conta ...
- iOS开发UI篇-tableView在编辑状态下的批量操作(多选)
先看下效果图 直接上代码 #import "MyController.h" @interface MyController () { UIButton *button; } @pr ...
- (四十二)tableView的滑动编辑和刷新 -局部刷新和删除刷新 -待解决问题
tableView的局部刷新有两个方法: 注意这个方法只能用于模型数据的行数不变,否则会出错. [self.tableView reloadRowsAtIndexPaths:<#(NSArray ...
- iOS tableView右滑显示选择
如何使用UITableViewRowAction实现右滑选择呢? 1.在iOS8以前,我们实现tableview中滑动显示删除,置顶,更多等等的按钮时,都需要自己去实现,在iOS8中系统已经写好了,只 ...
- 与TableView插入、删除、移动、多选,刷新控件
一.插入.删除.移动.多选 方法一: Cell的插入.删除.移动都有一个通用的方法,就是更新tableView的数据源,再reloadData,这样做实现上是简单一点,但是reloadData是刷新整 ...
- iOS学习30之UITableView编辑
1. UITableView编辑 1> UITableView 编辑流程 2> UITableView 编辑步骤(四步) ① 第一步 : 让 TableView 处于编辑状态(在按钮点击事 ...
- IOS第13天(3,私人通讯录,登陆状态数据存储,数据缓存, cell的滑动删除,进入编辑模式,单个位置刷新 )
*****联系人的界面的优化 HMContactsTableViewController.m #import "HMContactsTableViewController.h" # ...
随机推荐
- MYSQL管理----数据库删除恢复
(1) 如果备份了,就好解决了.略. (2)如果日志打开,使用mysqlbinlog来恢复. mysqlbinlog工具的使用,大家可以看MySQL的帮助手册.里面有详细的用, 在这个例子中,重点是- ...
- GoEasy消息推送
1. 从GoEasy获取appkey appkey是验证用户的有效性的唯一标识. 注册账号. GoEasy官网:https://goeasy.io 用注册好的账号登录到GoEasy的后台管理系统,创建 ...
- FZU 1056 扫雷游戏
水题.统计一下周围有几个雷. #include<cstdio> #include<cstring> #include<cmath> #include<algo ...
- MySQL协议分析2
MySQL协议分析 议程 协议头 协议类型 网络协议相关函数 NET缓冲 VIO缓冲 MySQL API 协议头 ● 数据变成在网络里传输的数据,需要额外的在头部添加4 个字节的包头. . packe ...
- javascript--study
1.函数传参:按值传递 对于数字.字符串等是将它们的值传递给了函数参数,函数参数的改变不会影响函数外部的变量. 对于数组和对象等是将对象(数组)的变量的值传递给了函数参数,这个变量保存的指向对象(数组 ...
- iOS开发网络篇之文件下载、大文件下载、断点下载
from: http://www.jianshu.com/p/f65e32012f07
- java8 stream ,filter 等功能代替for循环
直接上代码,比较实在. 对象A public Class A{ private Long id; private String userName; ..... ....省略get和set方法 } 在L ...
- UVa 11242 - Tour de France
题目大意:竞赛用自行车前轮有f个齿轮,后轮有r个齿轮,根据比率计算一个spread(传播率?). 很直接的题,排序然后找商的最大值就好了,uhunt上标明level 4,我都不敢相信会这么简单,还一直 ...
- spring3.1........jar包下载
1.common-dbcp-1.4.jar 下载地址:http://commons.apache.org/dbcp/ 2.common-pool-1.6.jar 下载地址:http://commons ...
- Quartz2D 之 简单使用
1. 获取Graphics Context CGContextRef ctx = UIGraphicsGetCurrentContext(); 2. 最后的渲染接口 CGContextStrokePa ...