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" # ...
随机推荐
- XML&AJAX
AJAX: Asynchronous Javascript and XML 1. 客户端触发异步操作 2. 创建新的XMLHttpRequest, 是重要的js对象,通过它提起对服务器端的请求 3. ...
- spring 5种通知
方法实现接口 package com.cn.spring.aop.impl; //加减乘除的接口类 public interface ArithmeticCalculator { int add(in ...
- Android L(5.0)源码之手势识别GestureDetector
本人新手,最近下了Android L的源码,正在研究手势识别,能力有限,现总结如下: Android识别触摸屏手势使得用户体验大大提高.在View类中有个View.OnTouchListener内部接 ...
- 【转】iOS开发路线简述
简单看了下楼主说的很详细,尤其是最后面那个图描述很直观,让想学习ISO开发的程序猿很清晰每个步骤学习的内容,在此收藏下. iOS系统以及iPhone的出来都要感谢乔布斯,一个完美主义者,从如此优秀的i ...
- Makefile — 基础
参考: 跟我一起写 Makefile GNU make <GNU+Make项目管理(第三版)> 1.Makefile用途 使用GNU Make工具来管理程序是每个Linux工程师必须掌握的 ...
- EF dbcontext上下文的处理
,那么我们整个项目里面上下文的实例会有很多个,我们又遇到了多次,当我们在编程的时候遇到多的时候,一般我们就要想想能不能解决多这个问题. (2)这里我要说的是EF上下文怎么管理呢?很简单啦,就是要保证线 ...
- Android 控件布局常用属性
<!--单个控件经常用到android:id —— 为控件指定相应的IDandroid:text —— 指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符串a ...
- bzoj3932
3932: [CQOI2015]任务查询系统 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 1326 Solved: 480[Submit][Sta ...
- Grunt构建工具插件篇——之less工具
Grunt--Less 摘要: 之前介绍了自动构建工具Grunt,其中有一个模块是"grunt-contrib-less",下面是配置Grunt自动编译less文件. 安装: Gr ...
- 分享Grunt.js配置: watch + liveReload 实时监测文件变化自动刷新浏览器
http://www.tuicool.com/articles/2eaQJn 用Grunt配置watch和liveReload组件,可以实时检测指定的文件变化并自动刷新浏览器.目前基本已经成为了我的必 ...