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