TableView中的编辑删除功能
来源:互联网 发布:网络安全法培训课件 编辑:程序博客网 时间:2024/05/16 13:02
简单的滑动删除比较简单,只要打开下面这个方法就行
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
对于编辑删除,也很简单,右上角添加一个“编辑”即可。
例子代码如下:
- (void)viewDidLoad
{
[superviewDidLoad];
UIBarButtonItem *editButton = [[UIBarButtonItemalloc]
initWithTitle:@"编辑"
style:UIBarButtonItemStyleDone
target:self
action:@selector(edit)];
self.navigationItem.rightBarButtonItem = editButton;
_tag = YES;
}
-(void) edit{
if (_tag ==YES) {
[self.tableViewsetEditing:YESanimated:YES];
//设置导航栏上右边的编辑按钮
UIBarButtonItem *editButton = [[UIBarButtonItemalloc]
initWithTitle:@"完成"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(edit)];
self.navigationItem.rightBarButtonItem = editButton;
_tag =NO;
}else {
[self.tableViewsetEditing:NOanimated:YES];
//设置导航栏上右边的编辑按钮
UIBarButtonItem *editButton = [[UIBarButtonItemalloc]
initWithTitle:@"编辑"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(edit)];
self.navigationItem.rightBarButtonItem = editButton;
_tag =YES;
}
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle ==UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableViewdeleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
DragBasicData *drugData = [[DragBasicDataalloc] init];
drugData = [self.dataControllerobjectInListAtIndex:indexPath.row];
[self.dataControllerdeleteBookMarkById:drugData.strDragId];
[selfrefreshDataList];
}
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 __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0){
return @"删除";
}
- (void)refreshDataList{
self.dataController = [[DragBasicDataListalloc] initBookMarks];
[[selftableView] reloadData];
}
- TableView中的编辑删除功能
- UITableViewController 编辑功能中的,添加,删除,修改
- UITableViewController 编辑功能中的,添加,删除,修改
- UITableViewController 编辑功能中的,添加,删除,修改
- iOS 开发-实现TableView的编辑功能以删除数据
- tableView编辑:插入、删除和移动
- CYC- tableView的删除编辑移动
- 编辑删除收藏在tableView的内容
- tableView上的侧滑删除功能
- TableView编辑
- TableView编辑
- iOS疯狂详解之tableview编辑添加删除
- tableView编辑模式下删除多个cell
- tableView编辑模式下删除多个cell
- tableView 如何设置仅某一行cell可以编辑删除
- TableView编辑中实现多行删除方法以及注意
- 编辑表格@tableView实现增加、删除、移动的操作
- tableView的编辑删除插入操作和UIAlertController的使用
- Android应用自动更新功能的实现!!!
- tomcat二级域名的配置
- spring集成axis2-1.5.6实现webservice服务器端及客户端
- jQuery基本原理
- [ASP.NET]如何在一个网站中定时执行一个任务
- TableView中的编辑删除功能
- 关于国内类Skillshare网站的思考
- Mac OSX 调用 Dylib
- VI/VIM/GVIM颜色自定义
- 判断文件权限的方法
- 软件架构设计方法学:敏捷思维
- 3D旋转UIView
- MySQL的Insert/replace/update/delete的几个使用方法
- c# 连接 SQL 另一篇