05.编辑模式-删除
来源:互联网 发布:unity3d手游大全 编辑:程序博客网 时间:2024/06/05 18:55
-(void)loadView
{
NSLog(@"开始了");
// self.view.backgroundColor=[UIColor redColor];
self.view=[[UIViewalloc] initWithFrame:[[UIScreenmainScreen] applicationFrame]];
UIToolbar *toolbar=[[UIToolbaralloc] initWithFrame:CGRectMake(0,0, 320, 44)];
[toolbar setTintColor:[UIColorredColor]];
UIBarButtonItem *space=[[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpacetarget:nilaction:nil];
//删除按钮
UIBarButtonItem *item1=[[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:selfaction:@selector(remove)];
[item1 setStyle:UIBarButtonItemStyleBordered];
[toolbarsetItems:@[space,item1]];
[self.viewaddSubview:toolbar];
UITableView *tableView=[[UITableViewalloc] initWithFrame:CGRectMake(0,44, 320, 416)style:UITableViewStylePlain];
[tableViewsetDataSource:self];
[tableViewsetDelegate:self];
[self.viewaddSubview:tableView];
self.tableView=tableView;
}
-(void)remove{
BOOL isEditing=[self.tableViewisEditing];
[self.tableViewsetEditing:!isEditing animated:YES];
}
- (void)viewDidLoad {
[superviewDidLoad];
NSMutableArray *array = [NSMutableArrayarrayWithCapacity:50];
for (NSInteger i =0; i < 50; i++) {
NSString *str = [NSStringstringWithFormat:@"d", i];
[arrayaddObject:str];
}
self.dataList = array;
}
#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataList.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:nil];
NSString *str = self.dataList[indexPath.row];
[cell.textLabelsetText:str];
return cell;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(UITableViewCellEditingStyleDelete==editingStyle) {
[self.dataListremoveObjectAtIndex:indexPath.row];
[self.tableViewdeleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationLeft];
NSLog(@"===%@==",self.dataList);
}
}
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"删除";
}
- 05.编辑模式-删除
- UITableView-编辑模式(多选移动删除)
- UI 一一 左滑删除,编辑模式,批量删除
- 非编辑模式下面实现对Cell的删除
- SQLServer编辑模式删除数据速度非常慢
- table的编辑模式(多选,插入,删除)
- tableView编辑模式下删除多个cell
- tableView编辑模式下删除多个cell
- iOS UITableViewCell (左滑删除按钮及编辑模式)
- UITableViewCell (左滑删除按钮及编辑模式)
- ubuntu进入vi编辑模式怎么删除内容
- iOS tableView 如何禁止滑动手势删除,只允许在编辑模式下进行删除Cell
- GridView删除,编辑应用
- GridView自定义编辑、删除
- GridView自定义编辑、删除
- GridView 的编辑删除
- GridView更新,编辑,删除
- gridview 编辑删除:
- 第17周上机实践项目4——日期结构体(1)
- leetcode:Majority Element
- 浅谈我对Java异常类的了解
- 光电整纬机(日本世联电子株式会社)
- 将WordPress作者存档链接中的用户名改为用户ID
- 05.编辑模式-删除
- 周总结
- cocos2dx3.1 texturepacker播放动画
- HDU1678 Shopaholic【水题】
- 颠倒数组中的所有元素
- WordPress 修改自定义文章类型的固定链接结构
- 杂谈
- jquery validate使用和扩展规则,jqueryvalidate
- 吝啬的国度 nyoj