Commit 48b18c093e2e1b1096fa82640e4d79904575ff46
1 parent
01bf2cae
no message
Showing
1 changed file
with
11 additions
and
5 deletions
CNLiveCollectionModule/Classes/Controller/CNLiveCollectionController.m
| @@ -48,7 +48,8 @@ static const CGFloat timeValue = 1.5; | @@ -48,7 +48,8 @@ static const CGFloat timeValue = 1.5; | ||
| 48 | 48 | ||
| 49 | [strongSelf.tableView.mj_header endRefreshing]; | 49 | [strongSelf.tableView.mj_header endRefreshing]; |
| 50 | [strongSelf.tableView.mj_footer endRefreshing]; | 50 | [strongSelf.tableView.mj_footer endRefreshing]; |
| 51 | - | 51 | + strongSelf.isRefreshing = NO; |
| 52 | + | ||
| 52 | if (error) { | 53 | if (error) { |
| 53 | [strongSelf.data removeAllObjects]; | 54 | [strongSelf.data removeAllObjects]; |
| 54 | [strongSelf.tableView reloadData]; | 55 | [strongSelf.tableView reloadData]; |
| @@ -64,7 +65,6 @@ static const CGFloat timeValue = 1.5; | @@ -64,7 +65,6 @@ static const CGFloat timeValue = 1.5; | ||
| 64 | if(strongSelf.pageNo == 1 && strongSelf.data.count > 0){ | 65 | if(strongSelf.pageNo == 1 && strongSelf.data.count > 0){ |
| 65 | [strongSelf.data removeAllObjects]; | 66 | [strongSelf.data removeAllObjects]; |
| 66 | } | 67 | } |
| 67 | - strongSelf.isRefreshing = NO; | ||
| 68 | strongSelf.pageNo++; | 68 | strongSelf.pageNo++; |
| 69 | [strongSelf.data addObjectsFromArray:array]; | 69 | [strongSelf.data addObjectsFromArray:array]; |
| 70 | if (array.count < strongSelf.pageSize) { | 70 | if (array.count < strongSelf.pageSize) { |
| @@ -205,13 +205,19 @@ static const CGFloat timeValue = 1.5; | @@ -205,13 +205,19 @@ static const CGFloat timeValue = 1.5; | ||
| 205 | _tableView.estimatedSectionHeaderHeight = 0; | 205 | _tableView.estimatedSectionHeaderHeight = 0; |
| 206 | _tableView.estimatedSectionFooterHeight = 0; | 206 | _tableView.estimatedSectionFooterHeight = 0; |
| 207 | [_tableView registerClass:[CNLiveCollectionCell class] forCellReuseIdentifier:kCNLiveCollectionCell]; | 207 | [_tableView registerClass:[CNLiveCollectionCell class] forCellReuseIdentifier:kCNLiveCollectionCell]; |
| 208 | + __weak __typeof(self)weakSelf = self; | ||
| 208 | _tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{ | 209 | _tableView.mj_header = [CNLiveRefreshHeader headerWithRefreshingBlock:^{ |
| 209 | - self.pageNo = 1; | ||
| 210 | - [self loadData]; | 210 | + __strong typeof(weakSelf) strongSelf = weakSelf; |
| 211 | + if(!strongSelf) return ; | ||
| 212 | + strongSelf.pageNo = 1; | ||
| 213 | + [strongSelf loadMoreData]; | ||
| 211 | 214 | ||
| 212 | }]; | 215 | }]; |
| 213 | CNLiveRefreshFooter *footer = [CNLiveRefreshFooter footerWithRefreshingBlock:^{ | 216 | CNLiveRefreshFooter *footer = [CNLiveRefreshFooter footerWithRefreshingBlock:^{ |
| 214 | - [self loadMoreData]; | 217 | + __strong typeof(weakSelf) strongSelf = weakSelf; |
| 218 | + if(!strongSelf) return ; | ||
| 219 | + [strongSelf loadMoreData]; | ||
| 220 | + | ||
| 215 | }]; | 221 | }]; |
| 216 | footer.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0]; | 222 | footer.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0]; |
| 217 | _tableView.mj_footer = footer; | 223 | _tableView.mj_footer = footer; |