GithubHelp home page GithubHelp logo

xiabob / lazyscrollview Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 5.0 20 KB

iOS 高性能异构滚动视图构建方案 —— LazyScrollView

License: MIT License

Objective-C 100.00%
scrollview ios-lazyscrollview lazyscrollview

lazyscrollview's Introduction

LazyScrollView

iOS 高性能异构滚动视图构建方案 —— LazyScrollView

##思路来源

已开源https://github.com/alibaba/LazyScrollView ##使用

使用方式和tableView类似,具体还是参照工程里面的例子。 ###dataSource

// ScrollView一共需要展示多少个item
- (NSUInteger)numberOfItemInScrollView:(LazyScrollView *)scrollView;
// 要求根据index直接返回RectModel
- (LSVRectModel *)scrollView:(LazyScrollView *)scrollView rectModelAtIndex:(NSUInteger)index;
// 返回下标所对应的view
- (UIView *)scrollView:(LazyScrollView *)scrollView itemByLsvId:(NSString *)lsvId;

其中LSVRectModel的定义如下:

// view转换后的绝对值rect
@property (nonatomic, assign) CGRect absRect;

// 业务下标,如果初始化时没有提供,LSVRectModel内部会自动生成
@property (nonatomic, copy) NSString *lsvId;

关键在于方法- (LSVRectModel *)scrollView:(LazyScrollView *)scrollView rectModelAtIndex:(NSUInteger)index,具体可以参见demo工程。

###delegate

//处理点击事件
- (void)scrollView:(LazyScrollView *)scrollView didClickItemAtIndex:(NSUInteger)index;

###调用核心API

- (void)reloadData;

重新走一遍DataSource的这些方法,等同于TableView中的reloadData

- (UIView *)dequeueReusableItemWithIdentifier:(NSString *)identifier

根据identifier获取可以复用的View。和TableView的dequeueReusableCellWithIdentifier:(NSString *)identifier方法意义相同。通常是在LazyScrollViewDatasource第三个方法,返回View的时候使用。

- (void)registerClass:(Class)viewClass forViewReuseIdentifier:(NSString *)identifier

功能和TableView的registerClass:(nullable Class)cellClass forCellReuseIdentifier:(NSString *)identifier一样 tableView

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.