首先记住声明编辑样式的属性  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的编辑的更多相关文章

  1. ios之UITableViewController(二) tableView的编辑模式

    tableView的编辑模式 表视图可以进入编辑模式,当进入编辑模式就可以进行删除.插入.移动单元等操作 效果图: 让表视图进入编辑模式,进入编辑模式的方法有两种,一种是使用导航栏的edit 按钮,另 ...

  2. iOS UIKit:TableView之编辑模式(3)

    一般table view有编辑模式和正常模式,当table view进入编辑模式时,会在row的左边显示编辑和重排控件,如图 42所示的编辑模式时的控件布局:左边的editing control有表 ...

  3. 07-UIKit(tableview的编辑模式、accessoryView)

    目录: 一.tableview的编辑模式-增删改查 二.不使用继承创建tableview 三.accessoryView辅助视图 回到顶部 一.tableview的编辑模式-增删改查 [1-conta ...

  4. iOS开发UI篇-tableView在编辑状态下的批量操作(多选)

    先看下效果图 直接上代码 #import "MyController.h" @interface MyController () { UIButton *button; } @pr ...

  5. (四十二)tableView的滑动编辑和刷新 -局部刷新和删除刷新 -待解决问题

    tableView的局部刷新有两个方法: 注意这个方法只能用于模型数据的行数不变,否则会出错. [self.tableView reloadRowsAtIndexPaths:<#(NSArray ...

  6. iOS tableView右滑显示选择

    如何使用UITableViewRowAction实现右滑选择呢? 1.在iOS8以前,我们实现tableview中滑动显示删除,置顶,更多等等的按钮时,都需要自己去实现,在iOS8中系统已经写好了,只 ...

  7. 与TableView插入、删除、移动、多选,刷新控件

    一.插入.删除.移动.多选 方法一: Cell的插入.删除.移动都有一个通用的方法,就是更新tableView的数据源,再reloadData,这样做实现上是简单一点,但是reloadData是刷新整 ...

  8. iOS学习30之UITableView编辑

    1. UITableView编辑 1> UITableView 编辑流程 2> UITableView 编辑步骤(四步) ① 第一步 : 让 TableView 处于编辑状态(在按钮点击事 ...

  9. IOS第13天(3,私人通讯录,登陆状态数据存储,数据缓存, cell的滑动删除,进入编辑模式,单个位置刷新 )

    *****联系人的界面的优化 HMContactsTableViewController.m #import "HMContactsTableViewController.h" # ...

随机推荐

  1. 函数之局部变量和使用global语句

    局部变量当你在函数定义内声明变量的时候,它们与函数外具有相同名称的其他变量没有任何关系,即变量名称对于函数来说是 局部 的.这称为变量的 作用域 .所有变量的作用域是它们被定义的块,从它们的名称被定义 ...

  2. js 日期控件laydate使用

    官网  http://sentsin.com/layui/laydate/ 1. 下载官网上的压缩包,解压后只需要复制laydate 文件夹到你的项目中; 2. 在页面引入  <script t ...

  3. (简单) LightOJ 1074 Extended Traffic,SPFA+负环。

    Description Dhaka city is getting crowded and noisy day by day. Certain roads always remain blocked ...

  4. MongoDB 3.0 WiredTiger Compression and Performance

    MongoDB3.0中的压缩选项 在MongoDB 3.0中,WiredTiger为集合提供三个压缩选项: 无压缩 Snappy(默认启用) – 很不错的压缩,有效利用资源 zlib(类似gzip) ...

  5. HUST 1602 Substring

    水题. #include<cstdio> #include<cstring> #include<cmath> #include<string> #inc ...

  6. ios 字体设计

    ref: http://ju.outofmemory.cn/entry/217705 ref:http://gold.xitu.io/entry/57958a41128fe10056be13b1 下面 ...

  7. Tsinsen-A1490 osu! 【数学期望】

    问题描述 osu!是一个基于<押忍!战斗!应援团><精英节拍特工><太鼓达人>等各种音乐游戏做成的一款独特的PC版音乐游戏.游戏中,玩家需要根据音乐的节奏,通过鼠标 ...

  8. 通过非root用户访问VNC

    我采用的是realvnc5.3.2.对于非root用户通过vnc访问linux桌面,网络上绝大数文章都是说要去配置/etc/sysconfig/vncservers.但安装完realvnc5.3.2之 ...

  9. 写一个程序,统计自己C语言共写了多少行代码。ver2.00

    概要 完成一个程序,作用是统计一个文件夹下面所有文件的代码行数.输入是一个文件夹的绝对路径,输出是代码行数.所以此程序的新特点有两个: 统计某一文件夹下的所有文件: 可以任意指定本机硬盘上任何位置的某 ...

  10. Ehcache jgroups方式同步缓存出现问题总结

    ehcache配置文件按官网配置如下: <?xml version="1.0" encoding="UTF-8"?> <ehcache> ...