[翻译] LTInfiniteScrollView
LTInfiniteScrollView

效果:

Usage - 使用
Create the scroll view by:
通过以下方式来创建出scroll view
self.scrollView = [[LTInfiniteScrollView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 200)];
[self.view addSubview:self.scrollView];
self.scrollView.dataSource = self;
[self.scrollView reloadData];
Then implement LTInfiniteScrollViewDataSource protocol:
然后实现LTInfiniteScrollViewDataSource协议方法:
@protocol LTInfiniteScrollViewDataSource <NSObject>
-(UIView*) viewAtIndex:(int)index reusingView:(UIView *)view;
-(int) totalViewCount;
-(int) visibleViewCount;
@end
Sample code:
示例源码:
-(int) totalViewCount
{
// you can set it to a very big number to mimic the infinite behavior, no performance issue here
return 100000000;
} -(int) visibleViewCount
{
return 5;
} -(UIView*) viewAtIndex:(int)index reusingView:(UIView *)view;
{
if(view){
((UILabel*)view).text = [NSString stringWithFormat:@"%d", index];
return view;
} UILabel *aView = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 64, 64)];
aView.backgroundColor = [UIColor blackColor];
aView.layer.cornerRadius = 32;
aView.layer.masksToBounds = YES;
aView.backgroundColor = [UIColor colorWithRed:0/255.0 green:175/255.0 blue:240/255.0 alpha:1];
aView.textColor = [UIColor whiteColor];
aView.textAlignment = NSTextAlignmentCenter;
aView.text = [NSString stringWithFormat:@"%d", index];
return aView;
}
If you want to apply any animation during scrolling, implement LTInfiniteScrollViewDelegateprotocol:
如果你想在滑动期间实现其他的动画效果,实现这个LTInfiniteScrollViewDelegateprotocol协议即可:
@protocol LTInfiniteScrollViewDelegate <NSObject>
-(void) updateView:(UIView*) view withDistanceToCenter:(CGFloat)distance scrollDirection:(ScrollDirection)direction;
@end
See the example for details~
请从示例源码中查看更多的细节~
[翻译] LTInfiniteScrollView的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- redis 持久化之 rdb 快照持久化
解释1: 虽然redis是单进程,但是它有一个单独的子进程进行rdb操作,为了保证的数据的一致性,当进行rdb操作失败的时候,主进程就停止写入 所以才有了stop-write-on-bgsave-er ...
- Linux常用命令之tr
tr NAME tr - translate or delete characters 可以对来自标准输入的字符进行替换.压缩和删除.它可以将一组字符变成另一组字符,经常用来编写优美的单行命令,作用很 ...
- 深入理解java集合框架之---------Arraylist集合 -----添加方法
Arraylist集合 -----添加方法 1.add(E e) 向集合中添加元素 /** * 检查数组容量是否够用 * @param minCapacity */ public void ensur ...
- 运行Rails server时,出 Error:Address already in use错误
运行dev@ubuntu:~/qq$ rails server出错 [2013-07-30 16:29:23] WARN TCPServer Error: Address already in us ...
- nodejs应用离线安装部署、卸载
公司写的文档,直接粘贴过来了: 本文档提供node应用一键安装.部署.卸载说明,包含对应脚本文件 默认版本:1.nodejs:v6.11.2.linux-x642.全局npm包:pm2.supervi ...
- [javaSE] GUI(鼠标事件)
调用Button对象的addMouseListener方法,参数:MouseListener对象,这个类是个接口,需要实现以下方法 mouseClicked mousePressed mouseRel ...
- 撩课-Python-每天5道面试题-第8天
一. 解释下什么是闭包? 有怎样的场景作用? 概念 在函数嵌套的前提下 内层函数引用了外层函数的变量(包括参数) 外层函数, 又把 内层函数 当做返回值进行返回 这个内层函数+所引用的外层变量, 称为 ...
- 从Eclipse切换到IDEA工具,哎~真香!
从Eclipse切换到IDEA工具,哎~真香!(图) 个人观点:IDEA工具用了就回不去了!!!对比很多人写,我就不赘述了.我在这里主要介绍一下IDEA工具的一些使用上的技巧,毕竟我开始学习java的 ...
- Lua脚本语言基础知识
注释 在Lua中,你可以使用单行注释和多行注释. 单行注释中,连续两个减号"--"表示注释的开始,一直延续到行末为止.相当于C++语言中的"//". 多行注 ...
- python学习之老男孩python全栈第九期_day024知识点总结——单继承、多继承
一. 单继承 class A:pass # 父类,也叫基类,也叫超类 class B:pass # 父类,也叫基类,也叫超类 class AB_son(A,B):pass # 子类,也叫派生类 cla ...