这篇文章主要介绍了IOS 开发之UITableView 删除表格单元写法的相关资料,这里提供实例帮助大家实现该功能,希望能帮助到大家,需要的朋友可以参考下
IOS 开发之UITableView 删除表格单元写法
实现代码:
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { NSDictionary *section = [data objectAtIndex:indexPath.section]; if (section) { NSMutableArray *content = [section valueForKey:@"content"]; if (content && indexPath.row < [content count]) { [content removeObjectAtIndex:indexPath.row]; } } [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { NSDictionary *section = [data objectAtIndex:indexPath.section]; if (section) { // Make a local reference to the editing view controller. EditingViewController *controller = self.editingViewController; NSMutableArray *content = [section valueForKey:@"content"]; // A "nil" editingItem indicates the editor should create a new item. controller.editingItem = nil; // The group to which the new item should be added. controller.editingContent = content; controller.sectionName = [section valueForKey:@"name"]; controller.editingTypes = [section valueForKey:@"types"]; [self.navigationController pushViewController:controller animated:YES]; } } }
那一行是要自己添加的 然后把新加那一行的属性设置成UITableViewCellEditingStyleInsert就行了
如有疑问请留言或者到本站社区交流讨论,以上就是IOS 中UITableView 删除表格单元写法的实例,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:
- iOS应用开发中UITableView的分割线的一些设置技巧
- 详解iOS开发中UITableview cell 顶部空白的多种设置方法
- IOS UITableViewCell详解及按钮点击事件处理实例
- 改变iOS应用中UITableView的背景颜色与背景图片的方法
- iOS App中UITableView左滑出现删除按钮及其cell的重用
- 全面解析iOS应用中自定义UITableViewCell的方法
- 详解iOS开发中UItableview控件的数据刷新功能的实现
- iOS UITableView 与 UITableViewController实例详解