ios开发之--UITableView中的visibleCells的用法
先上图:

具体代码如下:
#import "ViewController.h" @interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *myTableV;
@property(nonatomic,strong)NSArray *contentAry; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.contentAry = [NSArray array];
[self creatUI];
}
- (IBAction)leftAction:(id)sender {
self.contentAry = self.myTableV.visibleCells;
NSLog(@"----%@",self.contentAry); UIButton *button = (UIButton*)sender;
button.selected = !button.selected;
CGAffineTransform transform;
double duration = 0.1; if (button.tag == ) {
transform = CGAffineTransformMakeTranslation(-[UIScreen mainScreen].bounds.size.width, );
}else if (button.tag == )
{
for (UITableViewCell *cell in self.contentAry) {
[UIView animateWithDuration:duration delay: options: animations:^{
cell.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) { }];
duration += 0.1;
}
return;
}else
{
transform = CGAffineTransformMakeTranslation([UIScreen mainScreen].bounds.size.width, );
} for (UITableViewCell *cell in self.contentAry) {
[UIView animateWithDuration:duration delay: options: animations:^{
cell.transform = transform;
} completion:^(BOOL finished) { }];
duration += 0.1;
} } -(void)creatUI
{
self.myTableV = [[UITableView alloc]initWithFrame:CGRectMake(, , self.view.bounds.size.width, self.view.bounds.size.height - ) style:UITableViewStylePlain];
self.myTableV.delegate = self;
self.myTableV.dataSource = self;
self.myTableV.tableFooterView = [[UIView alloc]init];
[self.view addSubview:self.myTableV];
} -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return ;
} -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *celliden = @"CELLS";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:celliden];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:celliden];
}
cell.textLabel.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
cell.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.6];
return cell;
}
仅做记录!
ios开发之--UITableView中的visibleCells的用法的更多相关文章
- UITableView中的visibleCells的用法(visibleCells帮上大忙了)
这两天遇到一个问题,UITableView中需要加入动画,而且每一行的速度不一样. 刚开始做时把所有的cell都遍历一遍加上动画,后来发现,如果数据很多时,就会出现各种各样的问题,而且没有显示在界 ...
- 李洪强iOS开发之 - enum与typedef enum的用法
李洪强iOS开发之 - enum与typedef enum的用法 01 - 定义枚举类型 上面我们就在ViewController.h定义了一个枚举类型,枚举类型的值默认是连续的自然数,例如例子中的T ...
- iOS开发系列--UITableView全面解析
--UIKit之UITableView 概述 在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似于微信.QQ.新浪微博等软件基本上随处都是U ...
- iOS开发基础-UITableView控件简单介绍
UITableView 继承自 UIScrollView ,用于实现表格数据展示,支持垂直滚动. UITableView 需要一个数据源来显示数据,并向数据源查询一共有多少行数据以及每一行显示什么 ...
- iOS开发:UITableView的优化技巧-异步绘制Cell
最近在微博上看到一个很好的开源项目VVeboTableViewDemo,是关于如何优化UITableView的.加上正好最近也在优化项目中的类似朋友圈功能这块,思考了很多关于UITableView的优 ...
- iOS学习之UITableView中Cell的操作
接着iOS学习之Table View的简单使用 这篇,这里主要讲UITableView 中的Cell的操作,包括标记.移动.删除.插入. 为了简单快捷,直接从原来那篇的代码开始,代码下载地址:http ...
- iOS开发之动画中的时间(概况)
一.引言 在iOS开发中使用动画时,可以通过设置动画的duration.speed.begintime.offset属性,来设置动画的时长.速度.起始时间及起始偏移. 用一个简单的例子来说明各个参数的 ...
- iOS开发总结-UITableView 自定义cell和动态计算cell的高度
UITableView cell自定义头文件:shopCell.h#import <UIKit/UIKit.h>@interface shopCell : UITableViewCell@ ...
- iOS开发之UITableView中计时器的几种实现方式(NSTimer、DispatchSource、CADisplayLink)
最近工作比较忙,但是还是出来更新博客了.今天博客中所涉及的内容并不复杂,都是一些平时常见的一些问题,通过这篇博客算是对UITableView中使用定时器的几种方式进行总结.本篇博客会给出在TableV ...
随机推荐
- php 扩展包链接
https://pecl.php.net/package-stats.php?cid=7
- Materialize快速入门教程
https://materializecss.com/ https://github.com/Dogfalo/materialize http://www.materializecss.cn/ 1,下 ...
- Spring,hibernate,struts的面试笔试题(含答案)
Hibernate工作原理及为什么要用? 原理: 1.读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory 3.打开Sesssion 4.创建事务Transation 5.持久 ...
- Qt安装过程中: configure 时发生的经典出错信息之”Basic XLib functionality test failed!”(Z..z..) 之 MySQL support cannot be enabled due to functionality test!
整出错信息是在./configure阶段Basic XLib functionality test failed!You might need to modify the include and li ...
- nano 命令 linux
用途说明 nano是一个字符终端的文本编辑器,有点像DOS下的editor程序.它比vi/vim要简单得多,比较适合Linux初学者使用.某些Linux发行版的默认编辑器就是nano.(nano - ...
- svn -- svn安装与配置
1.SVN分为服务器端与客户端 l 服务器端:VisualSVN SubVersion l 客户端:TortoiseSVN server http://www.visualsvn.com/ cli ...
- Java内存、CPU占用率过高
windows下揪出java程序占用cpu很高的线程 并找到问题代码 死循环线程代码 linux下查找java进程占用CPU过高原因 Java 占用CPU使用率很高的分析 记一次线上Java程序导致服 ...
- char* 与 char[] 的区别
"Hello world"作为静态字符串实际上存储在数据区,但写程序的人不知道这个地址,而程序本身知道.当某一函数以{ char p[] = "Hello world&q ...
- andorid ndk 各种坑啊 记录下
android jni代码回调java的问题 因为多线程原因会导致找不到java类,无法call函数的问题 问题1找不到java类 在JNI_OnLoad的时候 保存下来 JNIEXPORT jint ...
- Php面向对象 – 类常量
Php面向对象 – 类常量 类常量:类中,保存执行周期内,不变的数据. 定义: constkeyword const 常量名 = 常量值 样例: class Student { public $st ...