//实现加载刷新
-(void)LoadingAndRefreshing{
//刷新
[_collectionView addHeaderWithCallback:^{
if (isRefreshing) { // warning: capturing self strongly in this block is likely to lead to a retain cycle
return ;
}
isRefreshing=YES;
currentPage=1;
[self downloadDataSource];
isRefreshing=NO;
[_collectionView headerEndRefreshing];
}];
//加载
[_collectionView addFooterWithCallback:^{
if (isLoading) { // warning: capturing self strongly in this block is likely to lead to a retain cycle
return ;
}
isLoading=YES;
currentPage++;
[self downloadDataSource];
isLoading=NO;
[_collectionView footerEndRefreshing];
}];
-(void)LoadingAndRefreshing{
//刷新
[_collectionView addHeaderWithCallback:^{
if (isRefreshing) { // warning: capturing self strongly in this block is likely to lead to a retain cycle
return ;
}
isRefreshing=YES;
currentPage=1;
[self downloadDataSource];
isRefreshing=NO;
[_collectionView headerEndRefreshing];
}];
//加载
[_collectionView addFooterWithCallback:^{
if (isLoading) { // warning: capturing self strongly in this block is likely to lead to a retain cycle
return ;
}
isLoading=YES;
currentPage++;
[self downloadDataSource];
isLoading=NO;
[_collectionView footerEndRefreshing];
}];
}
原因:是在block中使用局部变量或对象引起的。
解决:应该使用@property (strong, nonatomic) BOOL isRefreshing; 进行修饰