|
1 | 1 | # JSLoadMoreServiceDemo |
2 | 2 | [](https://github.com/josin22/JSLoadMoreService) |
3 | | -[](https://github.com/josin22/JSLoadMoreService) |
4 | 3 | [](https://github.com/josin22/JSLoadMoreService) |
5 | 4 |
|
6 | 5 | 让预加载,成为你分页的好朋友 |
|
9 | 8 |  |
10 | 9 |
|
11 | 10 | # 安装 |
12 | | -支持pod 安装 |
| 11 | +~~支持pod 安装~~ |
| 12 | + ~~pod 'JSLoadMoreService', '~> 1.1.0'~~ |
| 13 | + |
| 14 | +更新下:pod安装反而会更麻烦,所以遗弃pod,你可以直接拖着JSLoadMoreService文件到你的项目即可, |
| 15 | + |
| 16 | +# 注 |
| 17 | +依赖的三方库有:AFNetworking、ReactiveObjC、YYModel、MJRefresh |
| 18 | +# 使用 |
| 19 | +优雅的建一个viewmodel类, |
| 20 | +然后下面就是怎样调用分类的方法: |
| 21 | +```- (RACSignal *)siganlForJokeDataIsReload:(BOOL)isReload{ |
| 22 | + |
| 23 | + RACReplaySubject *subject = [RACReplaySubject subject]; |
| 24 | + [[self js_singalForSingleRequestWithURL:Test_Page_URL |
| 25 | + para:nil |
| 26 | + keyOfArray:@"pdlist" |
| 27 | + classNameOfModelArray:@"JSGoodListModel" |
| 28 | + isReload:isReload] subscribeNext:^(id _Nullable x) { |
| 29 | + /** |
| 30 | + * x : 分类方法(js_singalForSingleRequestWithURL:...)里 sendNext 传过来的数组 |
| 31 | + * 你可以对每次传过来的数组的元素"再加工",知道达到你的要求后 再 sendNext |
| 32 | + */ |
| 33 | + //... |
| 34 | + [subject sendNext:x]; |
| 35 | + } error:^(NSError * _Nullable error) { |
| 36 | + [subject sendError:error]; |
| 37 | + } completed:^{ |
| 38 | + /** |
| 39 | + * 走到这里为,每次分页请求所有逻辑处理完毕 |
| 40 | + */ |
| 41 | + [subject sendCompleted]; |
| 42 | + }]; |
| 43 | + |
| 44 | + return subject; |
| 45 | +} |
| 46 | +``` |
| 47 | +在你的cellForRowAtIndexPath:代理里选择调用回调 |
| 48 | +```** |
| 49 | + * 根据当期index计算是否回调preloadblock |
| 50 | + */ |
| 51 | + [self preloadDataWithCurrentIndex:indexPath.row]; |
| 52 | + ``` |
| 53 | +
|
| 54 | +优雅的配置tableview的上拉刷新和预加载 |
| 55 | +
|
| 56 | +```- (JSListTableView *)listTableView{ |
| 57 | + |
| 58 | + if (!_listTableView) { |
| 59 | + _listTableView = [[JSListTableView alloc] initWithFrame:self.view.bounds |
| 60 | + style:UITableViewStyleGrouped]; |
| 61 | + [self.view addSubview:_listTableView]; |
| 62 | + |
| 63 | + kWeakSelf(self) |
| 64 | + /** |
| 65 | + * 刷新 |
| 66 | + */ |
| 67 | + [_listTableView headerReloadBlock:^{ |
| 68 | + kStrongSelf(self) |
| 69 | + [self requestGoodListIsReload:YES]; |
| 70 | + }]; |
| 71 | + /** |
| 72 | + * 预加载 |
| 73 | + */ |
| 74 | + _listTableView.js_preloadBlock = ^{ |
| 75 | + kStrongSelf(self) |
| 76 | + [self requestGoodListIsReload:NO]; |
| 77 | + }; |
| 78 | + } |
| 79 | + return _listTableView; |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +详细的实现步骤请访问[我的博客](http://qiaotongxin.cc/2017/08/06/20170807/) |
| 84 | + |
| 85 | +如果用起来能让你愉悦,别忘记给个star,👍一下~ |
| 86 | +# JSLoadMoreServiceDemo |
| 87 | +[](https://github.com/josin22/JSLoadMoreService) |
| 88 | +[](https://github.com/josin22/JSLoadMoreService) |
| 89 | + |
| 90 | +让预加载,成为你分页的好朋友 |
| 91 | + |
| 92 | +# 丝滑的样子 |
| 93 | + |
| 94 | + |
| 95 | +# 安装 |
| 96 | +~~支持pod 安装~~ |
| 97 | + ~~pod 'JSLoadMoreService', '~> 1.1.0'~~ |
| 98 | + |
| 99 | +更新下:pod安装反而会更麻烦,所以遗弃pod,你可以直接拖着JSLoadMoreService文件到你的项目即可, |
13 | 100 |
|
14 | | - pod 'JSLoadMoreService', '~> 1.1.0' |
15 | | - |
16 | 101 | # 注 |
17 | 102 | 依赖的三方库有:AFNetworking、ReactiveObjC、YYModel、MJRefresh |
18 | 103 | # 使用 |
|
0 commit comments