tableView - 数据刷新
2015-06-19 01:14
344 查看
tableView数据刷新方法
重新刷新屏幕上的所有cell没有动画效果
[self.tableView reloadData];
刷新特定行的cell
有动画效果
[self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0] ] withRowAnimation:UITableViewRowAnimationLeft];
插入特定行数的cell
有动画效果
[self.tableView insertRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0] ] withRowAnimation:UITableViewRowAnimationLeft];
删除特定行数的cell
有动画效果
[self.tableView deleteRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection:0] ] withRowAnimation:UITableViewRowAnimationLeft];
数据刷新的原则
通过修改模型数据,来修改tableView的展示先修改模型数据
再调用数据刷新方法
不要直接修改cell上面子控件的属性
如果不要求动画效果,一般使用reloadData刷新数据
// 刷新,删除和刷新特定行要求,删除的和刷新的行数必须要相等 //- reloadRowsAtIndexPaths //- insertRowsAtIndexPaths //- insertRowsAtIndexPaths // 移除最前面两行(注意下标) [self.dealsData removeObjectAtIndex:0]; [self.dealsData removeObjectAtIndex:0];
相关文章推荐
- Linux Pthread 深入解析
- IOS编译报错:objc-class-ref in AppDelegate.o之解决方案
- oracle物化视图的两个典型应用场景
- 学习jetty server
- jquery对url中的中文解码
- UIScrollView的使用大全
- 我的Java开发学习之旅------>Java经典排序算法之希尔排序
- Android代码(Handler的运用),HttpURLConnection的应用,将url图片地址转换成图片。
- Android代码(Handler的运用),HttpURLConnection的应用,将url图片地址转换成图片。
- leetcode 226: Invert Binary Tree
- swift-字符串
- 在SAS数据集中插入列并赋值
- 课程改进意见
- Tomcat反向代理+负载均衡的四种方法配置
- 运行到自定义的AVPlayer时,程序崩在main函数里
- Java之Pull方式生成xml文件和解析xml文件
- Python转义字符
- AC自动机
- leetcode 225: Implement Stack using Queues
- java 程序语言中的LinkedList 集合基本方法演示