IOS 開發(fā)之UITableView 刪除表格單元寫法
更新時間:2017年08月17日 10:45:32 投稿:lqh
這篇文章主要介紹了IOS 開發(fā)之UITableView 刪除表格單元寫法的相關資料,這里提供實例幫助大家實現(xiàn)該功能,希望能幫助到大家,需要的朋友可以參考下
IOS 開發(fā)之UITableView 刪除表格單元寫法
實現(xiàn)代碼:
- (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就行了
如有疑問請留言或者到本站社區(qū)交流討論,以上就是IOS 中UITableView 刪除表格單元寫法的實例,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
您可能感興趣的文章:
- iOS應用開發(fā)中UITableView的分割線的一些設置技巧
- 詳解iOS開發(fā)中UITableview cell 頂部空白的多種設置方法
- IOS UITableViewCell詳解及按鈕點擊事件處理實例
- 改變iOS應用中UITableView的背景顏色與背景圖片的方法
- iOS App中UITableView左滑出現(xiàn)刪除按鈕及其cell的重用
- 全面解析iOS應用中自定義UITableViewCell的方法
- 詳解iOS開發(fā)中UItableview控件的數(shù)據(jù)刷新功能的實現(xiàn)
- iOS UITableView 與 UITableViewController實例詳解
相關文章
iOS10語音識別框架SpeechFramework應用詳解
在iOS10系統(tǒng)了,apple開放了與語音識別相關的接口,開發(fā)者可以將其應用到自己的App中,實現(xiàn)用戶通過語音進行功能操作。 這篇文章主要介紹了iOS10語音識別框架SpeechFramework應用,需要的朋友可以參考下2016-09-09iOS開發(fā)之使用Storyboard預覽UI在不同屏幕上的運行效果
使用Storyboard做開發(fā)效率非常高,為了防止在團隊中發(fā)生沖突,采取的解決辦法是負責UI開發(fā)的同事最好每人維護一個Storyboard, 公用的組件使用輕量級的xib或者純代碼來實現(xiàn),下面小編就給大家介紹如何使用Storyboard預覽UI在不同屏幕上的運行效果,需要的朋友可以參考下2015-08-08