Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alibaba/lazyscrollview
An iOS ScrollView to resolve the problem of reusability in views.
https://github.com/alibaba/lazyscrollview
ios lazyscrollview reusability scrollview tangram
Last synced: 1 day ago
JSON representation
An iOS ScrollView to resolve the problem of reusability in views.
- Host: GitHub
- URL: https://github.com/alibaba/lazyscrollview
- Owner: alibaba
- License: mit
- Created: 2017-03-02T02:30:22.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-04T07:40:06.000Z (almost 5 years ago)
- Last Synced: 2024-12-28T04:05:33.677Z (1 day ago)
- Topics: ios, lazyscrollview, reusability, scrollview, tangram
- Language: Objective-C
- Homepage:
- Size: 158 KB
- Stars: 1,775
- Watchers: 49
- Forks: 274
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CocoaPods](https://img.shields.io/cocoapods/v/LazyScroll.svg)]() [![CocoaPods](https://img.shields.io/cocoapods/p/LazyScroll.svg)]() [![CocoaPods](https://img.shields.io/cocoapods/l/LazyScroll.svg)]()
# LazyScrollView
[中文说明](http://pingguohe.net/2016/01/31/lazyscroll.html)
> 基于 LazyScrollView,我们创造了一个动态创建模块化 UI 页面的解决方案,详情可见 [Tangram-iOS](https://github.com/alibaba/tangram-ios)。
LazyScrollView is an iOS ScrollView, to resolve the problem of reusability of views.
Comparing to UITableView, LazyScrollView can easily create different layout, instead of the single row flow layout.
Comparing to UICollectionView, LazyScrollView can create views without Grid layout, and provides a easier way to create different kinds of layous in a ScrollView.
> We create a modular UI solution for building UI page dynamically based on `LazyScrollView`, you can see more info from this repo: [Tangram-iOS](https://github.com/alibaba/tangram-ios)
# Installation
LazyScroll is available as `LazyScroll` in CocoaPods.
pod 'LazyScroll'
You can also download the source files from [release page](https://github.com/alibaba/LazyScrollView/releases) and add them into your project manually.
# Usage
#import "TMMuiLazyScrollView.h"
Then, create LazyScrollView:
```objectivec
TMMuiLazyScrollView *scrollview = [[TMMuiLazyScrollView alloc]init];
scrollview.frame = self.view.bounds;
```Next, implement `TMMuiLazyScrollViewDataSource`:
```objectivec
@protocol TMMuiLazyScrollViewDataSource@required
// Number of items in scrollView.
- (NSUInteger)numberOfItemInScrollView:(TMMuiLazyScrollView *)scrollView;// Return the view model (TMMuiRectModel) by index.
- (TMMuiRectModel *)scrollView:(TMMuiLazyScrollView *)scrollView rectModelAtIndex:(NSUInteger)index;// Return view by the unique string that identify a model (muiID).
// You should render the item view here.
// You should ALWAYS try to reuse views by setting each view's reuseIdentifier.
- (UIView *)scrollView:(TMMuiLazyScrollView *)scrollView itemByMuiID:(NSString *)muiID;@end
```Next, set datasource of LazyScrollView:
```objectivec
scrollview.dataSource = self;
```Finally, do reload:
```objectivec
[scrollview reloadData];
```For more details, please clone the repo and open the demo project.