如何在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];
    }
  }
}

关于如何在IOS中使用UITableView 删除表格单元就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

名称栏目:如何在IOS中使用UITableView删除表格单元
网站路径:https://www.cdcxhl.com/article46/jcheeg.html

成都网站建设公司_创新互联,为您提供标签优化网站内链网页设计公司定制网站网站策划

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都seo排名网站优化