tableViewCell的依次插入动画
来源:互联网 发布:ape转换flac软件 编辑:程序博客网 时间:2024/05/18 03:26
如果有一个小需求当我们的tableView不是直接加载到界面上,而是cell依次展示到我们的界面上只一个动画效果,我们需要怎嘛做呢?
其实很简单,我们数据源有多少 我么就依次 插入多少个cell 不就行了吗? 需要注意的地方时是,当我们要插入的时候 要保证,下面返回的cell个数是对的就行了呗.
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return self.DatNum+1; }
下面是我的实现 直接拷贝代码沾到你的 ViewController.m里就行了
// ViewController.m// tableViewCellAnimation//// Created by 3D on 16/6/24.// Copyright © 2016年 3D. All rights reserved.//#import "ViewController.h"@interface ViewController () <UITableViewDataSource,UITableViewDelegate>@property(nonatomic,strong)UITableView *tableView;@property(nonatomic,strong)NSArray *dataArr;@property(nonatomic,strong)NSMutableArray *indesPaths;@property (nonatomic,assign)int DatNum;@property(nonatomic,strong) NSTimer * timer;@end@implementation ViewController-(UITableView *)tableView{if (!_tableView) { _tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; } return _tableView;}-(NSArray *)dataArr{if (!_dataArr) { _dataArr = @[@"我是个1", @"我是个2", @"我是个3", @"我是个4", @"我是个5", @"我是个6", @"我是个7", @"我是个8", @"我是个9", @"我是个10", @"我是个11", @"我是个12", @"我是个13", @"我是个14", @"我是个15", ]; } return _dataArr;}- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.[self.view addSubview:self.tableView];self.DatNum = -1; NSMutableArray *indexPaths = @[].mutableCopy; self.indesPaths = indexPaths; self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(charusell) userInfo:nil repeats:YES]; }-(void)charusell{self.DatNum = self.DatNum +1;if (self.DatNum < self.dataArr.count) { [self.indesPaths addObject:[NSIndexPath indexPathForItem:self.DatNum inSection:0]]; [self.tableView insertRowsAtIndexPaths:self.indesPaths withRowAnimation:UITableViewRowAnimationRight]; [self.indesPaths removeAllObjects];}else{ [self.timer invalidate]; //记得当不用这个定时器的时候要销毁. self.timer = nil; }}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return self.DatNum+1; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];cell.textLabel.text = self.dataArr[indexPath.row];return cell; }@end
效果如下
推荐拓展阅读
举报文章
文/大墙66370(简书作者)
原文链接:http://www.jianshu.com/p/ff0db8fafd0c
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
原文链接:http://www.jianshu.com/p/ff0db8fafd0c
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
0 0
- tableViewCell的依次插入动画
- tableViewCell的依次插入动画
- iOS TableViewCell 加载时的动画
- 依次加载listview的每一个item实现动画的效果
- TableViewCell加动画
- 给TableViewCell添加动画
- TableViewCell的美化及带动画插入行
- iOS 给tableViewCell添加动画
- iOS之TableViewCell加载动画
- XML+DOM将元素的数据依次插入到表格中
- android的动画插入器
- Android动画探索——图标依次变大的水滴效果
- 案列:使用pop实现发布界面6个按钮依次坠落的动画
- [个性化你的App]iOS:实现类似于google+的tableviewcell卡片式插入效果
- swift扩展UIView实现动画依次执行
- 新浪微博,按钮依次弹出动画
- android 多个控件依次执行动画
- 【iOS开发系列】tableViewCell简单动画
- Android studio mac/windows 常用快捷键
- restful components pagination
- CPU 的实模式 保护模式
- Android真机调试打印日志的方法
- Fragment onActivityResult
- tableViewCell的依次插入动画
- iOS中原生APP与JS交互 之 WebViewJavascriptBridge 的简单用法
- MemoryHeapBase与MemoryBase
- easyui的datagrid导出为excel
- 关于volley的get、post、put、delete方法
- socketIO-IOS实现即时通讯
- 设计模式之工厂方法模式
- Think in java笔记 final
- C/C++函数指针变量调用函数