UITableView划动删除的实现
来源:互联网 发布:mac照片和iphoto 编辑:程序博客网 时间:2024/05/15 12:44
UITableView划动删除的实现
2013-04-21 17:21:25| 分类:默认分类 | 标签:|举报|字号大中小 订阅
从七八月前对苹果一无所知,到现在手持iphone,ipad,itouch有三个线上成熟app并熟练开发ios应用.一路走来一直站在前辈的肩膀上不断进步.如今生活工作稳定是时候将一直以来的一些心得整理出来了.想来想去决定先说说UITableView.
#imp
ort <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 da
ta 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 @"下载";
}
本文出自 “rainbird” 博客,请务必保留此出处http://rainbird.blog.51cto.com/211214/634587
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView划动删除的实现
- UITableView实现划动删除
- UITableView划动删除cell一行的实现
- IOS之UITableView划动删除的实现
- IOS 如何实现UITableView的划动删除
- 获取屏幕属性的工具类
- VC++ 6.0 fscanf fprintf用法
- windows 安装hadoop
- wav文件格式详解
- iOS学习之UINavigationController详解与使用(二)页面切换和segmentedController
- UITableView划动删除的实现
- Java开发中的乱码问题
- 用MATLAB信号处理工具箱进行FIR滤波器设计的三种方法
- ios程序启动原理与窗口、控制加载、控制器view加载、导航控制器加载
- Caused by: java.lang.OutOfMemoryError: Java heap space错误原因及解决方法
- iOS学习之UINavigationController详解与使用(三)ToolBar
- C语言中Const的用法
- Qt学习笔记外观篇(二):QStyle
- JAVA基础(11) 系统日志