UITableView划动删除的实现
- #import <UIKit/UIKit.h>
- @interface UITableCellSwapDeleteViewController : UIViewController <UITableViewDelegate>{
- IBOutlet UITableView *testTableView;
- NSMutableArray *dataArray;
- }
- @property (nonatomic, retain) UITableView *testTableView;
- @property (nonatomic, retain) NSMutableArray *dataArray;
- @end
- - (void)viewDidLoad {
- [super viewDidLoad];
- dataArray = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
- return [dataArray count];
- }
- // Customize the appearance of table view cells.
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
- }
- // Configure the cell...
- cell.textLabel.text = [dataArray objectAtIndex:indexPath.row];
- return cell;
- }
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
- return YES;
- }
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- [dataArray removeObjectAtIndex:indexPath.row];
- // Delete the row from the data source.
- [testTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
- }
- }
- - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
- return @"下载";
- }
相关文章:
UITableView多选删除,类似mail中的多选删除效果
具体代码见附件
本文出自 “rainbird” 博客,请务必保留此出处http://rainbird.blog.51cto.com/211214/634587
UITableView划动删除的实现的更多相关文章
- iOS UITableView划动删除的实现
标签:划动删除 iphone 滑动删除 ios UITableView 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://rainb ...
- ios UITableView多选删除
第一步, - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath ...
- UItableView的编辑--删除移动cell
// // RootViewController.m // UI__TableView的编辑 // // Created by dllo on 16/3/17. // Copyright © 2016 ...
- jquery左划出现删除按钮,右滑隐藏
jquery左侧划出显示删除按钮,右滑动隐藏删除按钮 <!doctype html> <html> <head> <meta charset="ut ...
- Swift基础--手势识别(双击、捏、旋转、拖动、划动、长按)
// // ViewController.swift // JieUITapGestureRecognizer // // Created by jiezhang on 14-10-4. // ...
- android提供ToolBar实现划动菜单的陷阱
代码如下: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android: ...
- iphone练习之手势识别(双击、捏、旋转、拖动、划动、长按)UITapGestureRecognizer
首先新建一个基于Sigle view Application的项目,名为GestureTest;我的项目结构如下: 往viewController.xib文件里拖动一个imageView,并使覆盖整个 ...
- Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍
1.UITapGestureRecognizer 点击/双击手势 代码如下: var tapGesture = UITapGestureRecognizer(target: self, action: ...
- ios7禁止默认划动返回
self.navigationController.interactivePopGestureRecognizer.enabled = NO; 或 在使用之前先要判断是否ios7,不然会导致crash ...
随机推荐
- 修改主机名hostname
关于修改linux hostname的问题,尤其是redhat 7修改hostname的方式 2017年03月29日 13:56:45 阅读数:4989 首先强调一点,不同的系统,或者同一个系统的不同 ...
- 【Unity笔记】Behaviour Designer的使用方法
Tasks列表 -- Composites选项 Sequence:图标是“箭头”,相当于And逻辑.下接多个子任务,它们从左到右依次执行.所有子任务执行成功,则Sequence返回成功:任一子任务执行 ...
- 【Unity笔记】常用插件
记录一些常见插件,随时补充. iTween动画插件 原理:插值法,给出初始值和终点值,自动算出中间值. DoTween Tween动画 Playmaker $45 Playmaker由第三方软件商Hu ...
- 网络硬盘录像机和数字硬盘录像机区别(nvr dvr ipc区别)
DVR Digital Video Recorder 数字硬盘录像机 NVR Network Video Recorder 网络硬盘录像机 DVR(数字硬盘录像机)和NVR(网络硬盘录像机)在 ...
- CentOS每次开机都要ifup eth0的解决方法小结
vim /etc/sysconfig/network-scripts/ifcfg-eth0 把里面的 ONBOOT 设为 yes 即可. [编辑]艺搜参考 http://www.jbxue.com/L ...
- js学习笔记21----表格操作
1.获取表格元素: tHead : 表格头 tBody : 表格主体内容 tFoot : 表格尾 rows : 表格行 cells : 表格列 如获取表格第一行第一列的数据: <script ...
- 判断IE浏览器的最简洁方法
<script type='text/javascript'> var ie = !-[1,]; alert(ie);</script>
- IE屏蔽鼠标右键、禁止复制粘贴等功能
<body oncontextmenu="return false" onselectstart="return false" ondragstart=& ...
- numpy库中的知识点——积累
下面是一些杂碎的知识点: 首先我们说说多维数组: 数组的属性: ndarray.ndim, 表示数组的秩是多少: ndarray.shape,返回数组的形状: ndarray.size,数组元素的总个 ...
- R语言低级绘图函数-rect
rect 函数用来在一张图上添加矩形,只需要指定左下角和右上角的坐标的位置,就可以画出一个矩形 基本用法: plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), ...