Skip to content

xiabob/LazyScrollView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published