UICollectionView+XHWebImageAutoSize.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // UICollectionView+XHWebImageAutoSize.m
  3. // XHWebImageAutoSizeExample
  4. //
  5. // Created by zhuxiaohui on 2017/10/25.
  6. // Copyright © 2017年 it7090.com. All rights reserved.
  7. // https://github.com/CoderZhuXH/XHWebImageAutoSize
  8. #import "UICollectionView+XHWebImageAutoSize.h"
  9. #import "XHWebImageAutoSize.h"
  10. @implementation UICollectionView (XHWebImageAutoSize)
  11. -(void)xh_reloadDataForURL:(NSURL *)url{
  12. BOOL reloadState = [XHWebImageAutoSize reloadStateFromCacheForURL:url];
  13. if(!reloadState){
  14. [self reloadData];
  15. [XHWebImageAutoSize storeReloadState:YES forURL:url completed:nil];
  16. }
  17. }
  18. #pragma mark- 过期
  19. -(void)xh_reloadItemAtIndexPath:(NSIndexPath *)indexPath forURL:(NSURL *)url{
  20. BOOL reloadState = [XHWebImageAutoSize reloadStateFromCacheForURL:url];
  21. if(!reloadState){
  22. [self reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
  23. [XHWebImageAutoSize storeReloadState:YES forURL:url completed:nil];
  24. }
  25. }
  26. -(void)xh_reloadItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths forURL:(NSURL *)url{
  27. BOOL reloadState = [XHWebImageAutoSize reloadStateFromCacheForURL:url];
  28. if(!reloadState){
  29. [self reloadItemsAtIndexPaths:indexPaths];
  30. [XHWebImageAutoSize storeReloadState:YES forURL:url completed:nil];
  31. }
  32. }
  33. @end