首先记住声明编辑样式的属性  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. (简单) POJ 3414 Pots,BFS+记录路径。

    Description You are given two pots, having the volume of A and B liters respectively. The following ...

  2. EnablePrefetcher注册表项的修改与电脑提速

    前些天在图书馆找教材,偶然发现一本windows dos命令应用技巧的书,发现了几个有用的注册表项 EnablePrefetcher这个注册表项是windows用来控制系统预读取数据开放程度的参数,其 ...

  3. UIAlertView使用全解

    举例: UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Default Alert View"messa ...

  4. iOS开发之圆角指定 分类: ios技术 2015-05-25 16:26 191人阅读 评论(0) 收藏

    如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架).而若要指定某几个角(小于4)为圆角而别的不变时 ...

  5. mysql查看sql语句执行时间

    原文地址: http://www.cnblogs.com/happySmily/p/5943311.html

  6. Unknown/unsupported storage engine: InnoDB

    症状:无法启动mysql,在“mysql数据库目录/主机名.err”日志文件中报错 Unknown/unsupported storage engine: InnoDB原因:MySQL5.5.8 GA ...

  7. Thinking in scala (6)----高阶函数----返回一个函数

    在Thinking in scala (5)----高阶函数* 里面,我们演示了如何把一个函数作为参数传递给另外一个函数. 在本文里面,我们来演示函数式编程另外一个重要的特性:返回一个函数.首先来看这 ...

  8. CocoaPods 更新慢&swift版本适配

    一.更新慢的问题 使用CocoaPods来添加第三方类库,无论是执行pod install还是pod update都卡在了Analyzing dependencies不动 原因在于当执行以上两个命令的 ...

  9. 分析java堆

    内存溢出(OutOfMemory) OOM 堆溢出 直接内存溢出 永久区溢出

  10. Redis 排行榜 自己简单练习

    <?php class Ranks{ const PREFIX = 'zhengban'; protected $redis = ''; /* 初始化 */ public function __ ...