UITableView--增删&滚动

//UITableView的ADD

// NSString *name = @"new";

//NSInteger section = indexPath.section;

NSMutableArray *newArray = [dataArray objectAtIndex:indexPath.section];

[newArray addObject:dataArray [indexPath.section] [indexPath.row]];

//NSInteger row =  newArray.count - 1;

NSIndexPath *path = [NSIndexPath indexPathForRow:newArray.count- 1 inSection:indexPath.section];

[tableView insertRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationFade];

//UITableView的DELETE

NSMutableArray *lastArray =dataArray[indexPath.section];

if(lastArray.count> 0) {

[lastArray removeObjectAtIndex:indexPath.row];

}

[tableView reloadData];


设置自动滚动

NSIndexPath  path = [NSIndexPath indexPathForRow:dataArray.count- 1 inSection:0];

[tables crollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionBottom animated:YES];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 时间管理类的应用中插入编辑的效果 惯例先上gif如下 思路 1.拖拽视图效果的实现###### 2.列表中的cel...
    ChrisPzzz阅读 813评论 4 7
  • 插入行。删除行。折叠区。设置索引。刷新表格。注册cell。 //UITableView的ADD // NSStri...
    nothing_c阅读 212评论 0 0
  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 9,093评论 3 38
  • 前言 最近忙完项目比较闲,想写一篇博客来分享一些自学iOS的心得体会,希望对迷茫的你有所帮助。博主非科班出身,一些...
    GitHubPorter阅读 1,458评论 9 5
  • 自定义单元格 表格无论有多少中自定义单元格样式 每一种自定义单元格都有复用的能力所以每一个单元格都要带有一个静态局...
    DVWang阅读 282评论 0 0