iOS UITableView划动删除的实现
从七八月前对苹果一无所知,到现在手持iphone,ipad,itouch有三个线上成熟app并熟练开发ios应用.一路走来一直站在前辈的肩膀上不断进步.如今生活工作稳定是时候将一直以来的一些心得整理出来了.想来想去决定先说说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
iOS UITableView划动删除的实现的更多相关文章
- UITableView划动删除的实现
对于app应用来说,使用列表的形式展现数据非UITableView莫属.在熟练掌握了用UITableView展示数据以后,是不是也遇到了需要删除数据的需求?是不是觉得在一行数据上划动一下,然后出现一个 ...
- ios UITableView多选删除
第一步, - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath ...
- IOS UITableView多选删除功能
UITbableView作为列表展示信息,除了展示的功能,有时还会用到删除,比如购物车.收藏列表等. 单行删除功能可以直接使用系统自带的删除功能,当横向轻扫cell时,右侧出现红色的删除按钮,点击删除 ...
- 【转】iOS UITableView的方法解析
原文网址:http://www.cnblogs.com/wfwenchao/articles/3718742.html - (void)viewDidLoad { [super viewDidLoad ...
- UItableView的编辑--删除移动cell
// // RootViewController.m // UI__TableView的编辑 // // Created by dllo on 16/3/17. // Copyright © 2016 ...
- IOS UITableView NSIndexPath属性讲解
IOS UITableView NSIndexPath属性讲解 查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...
- jquery左划出现删除按钮,右滑隐藏
jquery左侧划出显示删除按钮,右滑动隐藏删除按钮 <!doctype html> <html> <head> <meta charset="ut ...
- Swift基础--手势识别(双击、捏、旋转、拖动、划动、长按)
// // ViewController.swift // JieUITapGestureRecognizer // // Created by jiezhang on 14-10-4. // ...
- Pop - Facebook 开源 iOS & OS X 动画库
Pop 是一个可扩展的 iOS & OS X 动画引擎.除了基本的静态动画,它支持弹簧和动态衰减的动画,因此可以用于构建现实的,基于物理的交互效果. 它的 API 可以与现有的 Objecti ...
随机推荐
- 体验了把做HR的感觉,上午看了40份简历,说说感受
原文链接:http://huachichi.info/2013/06/26/experience-of-being-a-hr/ 这两天准备从IBM离职,不要问我为什么要在这么bug的时间离职,总之 ...
- Google两步验证安装使用方法
http://www.williamlong.info/archives/2754.html
- atitit. web组件化原理与设计
atitit. web组件化原理与设计 1. Web Components提供了一种组件化的推荐方式,具体来说,就是:1 2. 组件化的本质目的并不一定是要为了可复用,而是提升可维护性. 不具有复用 ...
- Atitit. 脚本语言的断点单步调试的设计与实现 attialx 总结 php 参照java
Atitit. 脚本语言的断点单步调试的设计与实现 attialx 总结 php 参照java 1. 断点的实现:手动断点 die和exit是等价的 1 2. 变量表的实现 1 3. print_r( ...
- atitit.session的原理以及设计 java php实现的异同
atitit.session的原理以及设计 java php实现的异同 1. session的保存:java在内存中,php脚本因为不能常驻内存,所以在文件中 1 2. php的session机制 1 ...
- Reveal使用教程
Reveal使用教程 Reveal是用于透视程序整体结构的一个软件,软件收费89美刀,试用期30天,不过好在有破解版,无需担心花钱的问题 在然后呢,软件在哪下,可以在我的github上下载到破解版本 ...
- JQuery EasyUI datagrid pageNumber 分页 请求/加载 两次
解决方案: 原因是 jquery.easyui.min.js 源文件中,由于第1页的total和其他页的total不相等,EasyUI会重新发起第1页的请求!1.jQuery EasyUI 1.4.1 ...
- c# 获取Excel内容的分析
现在主流的Excel文档有2003和2007 c#获取 Excel2003 连接字符串 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0; ...
- (译)Getting Started——1.2.1 Defining the Concept(确定理念)
每个出色的应用都是由理念开始的.在开发应用时,你不需要把理念完善和完成后再进行开发.但是你确实需要确定你要做什么,做完后的效果如何. 为了定义理念,问自己以下的问题: 应用的受众是哪些人?应用的内容和 ...
- BZOJ2820 YY的GCD 莫比乌斯+系数前缀和
/** 题目:BZOJ2820 YY的GCD 链接:http://www.cogs.pro/cogs/problem/problem.php?pid=2165 题意:神犇YY虐完数论后给傻×kAc出了 ...