|
16 | 16 | #import "ProjectAboutMeListCell.h" |
17 | 17 | #import "ProjectAboutOthersListCell.h" |
18 | 18 | #import "ProjectPublicListCell.h" |
| 19 | +#import "SVPullToRefresh.h" |
19 | 20 |
|
20 | 21 | @interface ProjectListView ()<UISearchBarDelegate, SWTableViewCellDelegate> |
21 | 22 | @property (nonatomic, strong) Projects *myProjects; |
@@ -90,7 +91,12 @@ - (id)initWithFrame:(CGRect)frame projects:(Projects *)projects block:(ProjectLi |
90 | 91 |
|
91 | 92 | _myRefreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView]; |
92 | 93 | [_myRefreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged]; |
| 94 | + __weak typeof(self) weakSelf = self; |
93 | 95 |
|
| 96 | + [_myTableView addInfiniteScrollingWithActionHandler:^{ |
| 97 | + [weakSelf refreshMore]; |
| 98 | + }]; |
| 99 | + |
94 | 100 | if (_myProjects.list.count > 0) { |
95 | 101 | [_myTableView reloadData]; |
96 | 102 | }else{ |
@@ -167,14 +173,26 @@ - (void)refreshFirst{ |
167 | 173 | } |
168 | 174 | } |
169 | 175 |
|
| 176 | +- (void)refreshMore{ |
| 177 | + if (_myProjects.isLoading || !_myProjects.canLoadMore) { |
| 178 | + [_myTableView.infiniteScrollingView stopAnimating]; |
| 179 | + return; |
| 180 | + } |
| 181 | + _myProjects.willLoadMore = YES; |
| 182 | + [self sendRequest]; |
| 183 | +} |
| 184 | + |
| 185 | + |
170 | 186 | - (void)sendRequest{ |
171 | 187 | if (_myProjects.list.count <= 0) { |
172 | 188 | [self beginLoading]; |
173 | 189 | } |
174 | 190 | __weak typeof(self) weakSelf = self; |
175 | 191 | [[Coding_NetAPIManager sharedManager] request_Projects_WithObj:_myProjects andBlock:^(Projects *data, NSError *error) { |
176 | 192 | [weakSelf.myRefreshControl endRefreshing]; |
177 | | - [self endLoading]; |
| 193 | + [weakSelf endLoading]; |
| 194 | + [weakSelf.myTableView.infiniteScrollingView stopAnimating]; |
| 195 | + |
178 | 196 | if (data) { |
179 | 197 | [weakSelf.myProjects configWithProjects:data]; |
180 | 198 | [weakSelf setupDataList]; |
|
0 commit comments