UITableView+XHWebImageAutoSize.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // UITableView+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 "UITableView+XHWebImageAutoSize.h"
  9. #import "XHWebImageAutoSizeConst.h"
  10. #import "XHWebImageAutoSize.h"
  11. @implementation UITableView (XHWebImageAutoSize)
  12. -(void)xh_reloadDataForURL:(NSURL *)url{
  13. BOOL reloadState = [XHWebImageAutoSize reloadStateFromCacheForURL:url];
  14. if(!reloadState){
  15. [self reloadData];
  16. [XHWebImageAutoSize storeReloadState:YES forURL:url completed:nil];
  17. }
  18. }
  19. #pragma mark-过期
  20. -(void)xh_reloadRowAtIndexPath:(NSIndexPath *)indexPath forURL:(NSURL *)url{
  21. [self xh_reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone forURL:url];
  22. }
  23. -(void)xh_reloadRowAtIndexPath:(NSIndexPath *)indexPath withRowAnimation:(UITableViewRowAnimation)animation forURL:(NSURL *)url{
  24. BOOL reloadState = [XHWebImageAutoSize reloadStateFromCacheForURL:url];
  25. if(!reloadState){
  26. [self reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:animation];
  27. [XHWebImageAutoSize storeReloadState:YES forURL:url completed:nil];
  28. }
  29. }
  30. -(void)xh_reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths forURL:(NSURL *)url{
  31. [self xh_reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone forURL:url];
  32. }
  33. -(void)xh_reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation forURL:(NSURL *)url{
  34. BOOL reloadState = [XHWebImageAutoSize reloadStateFromCacheForURL:url];
  35. if(!reloadState){
  36. [self reloadRowsAtIndexPaths:indexPaths withRowAnimation:animation];
  37. [XHWebImageAutoSize storeReloadState:YES forURL:url completed:nil];
  38. }
  39. }
  40. @end