zoukankan      html  css  js  c++  java
  • [翻译] 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~

    请从示例源码中查看更多的细节~

  • 相关阅读:
    (转)EDM邮件制作规范完整版
    (转)Gmail,你必须了解的12个邮件编码问题
    说说CakePHP的关联模型之一 基本关联
    HTML5 离线应用程序
    CakePHP模型中使用join的多种写法
    判断浏览器
    Javascript闭包例子
    安装wamp后,其显示目录的图标显示不出来
    underscore.js 分析 第二天
    HTML5心得
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4209509.html
Copyright © 2011-2022 走看看