GHRefreshTableView.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // GHRefreshTableView.h
  3. // GameHelper
  4. //
  5. // Created by 青秀斌 on 16/12/29.
  6. // Copyright © 2016年 kylincc. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "CarRefreshHeadView.h"
  10. #import "GHRefreshHeader.h"
  11. @protocol GHRefreshTableViewDelegate;
  12. NS_ASSUME_NONNULL_BEGIN
  13. @interface GHRefreshTableView : UITableView
  14. @property (weak, nonatomic) IBOutlet id<GHRefreshTableViewDelegate> refreshDelegate;
  15. @property (strong, nonatomic, readonly) NSMutableArray *dataArray;
  16. @property (assign, nonatomic, readonly) NSUInteger pageIndex;
  17. @property (assign, nonatomic) NSUInteger pageSize;
  18. @property (nonatomic, copy) void (^reloadView)(NSArray *list); //自定义加载数据方法
  19. @property (assign, nonatomic) BOOL allowShowMore; //是否显示加载更多(默认显示)
  20. @property (assign, nonatomic) BOOL allowShowBlank; //是否显示占位图(默认显示)
  21. @property (assign, nonatomic) BOOL allowShowNoNetworkBlank; //是否显示无网占位图(默认显示)
  22. @property (assign, nonatomic) BOOL allowCarRefreshAnimation; //允许车辆刷新动画
  23. @property (assign, nonatomic) BOOL allowExternalControlShowBlank; //是否由外部设置showBlankView控制占位图(默认NO)
  24. @property (assign, nonatomic) BOOL allowShowBlankWithHeaderTableView; //是否将内容提示加载在HeaderTableView上(默认NO)
  25. @property (assign, nonatomic) BOOL allowShowBlankWithHeaderTableViewByNotDeveloped; //是否将内容提示加载在HeaderTableView上,表示“敬请期待”(默认NO)
  26. @property (assign, nonatomic) CarRefreshBackgroundType carRefreshBackgroundType;
  27. @property (nullable, strong, nonatomic) NSString *blankImage;
  28. @property (nullable, strong, nonatomic) NSString *blankTitle;
  29. @property (nullable, strong, nonatomic) NSString *blankMessage;
  30. @property (assign, nonatomic) CGFloat offsetY;
  31. @property (assign, nonatomic) BOOL isLoad;
  32. @property (nullable, nonatomic, strong) GHRefreshHeader *refreshHeaderView;
  33. // 移除“没有数据”文字+图片
  34. -(void)removeBlackView;
  35. // 重新设置BlankView的位置
  36. -(void)showBlankView_offsetY:(CGFloat)offsetY;
  37. // 移除 头view
  38. -(void)removeHeaderView;
  39. // 重新刷新数据+下拉动画
  40. - (void)refreshData;
  41. // 重新刷新数据 不+下拉动画
  42. - (void)refreshDataNoAnimation;
  43. // 添加“没有数据”文字+图片
  44. - (void)showBlankView:(NSString *)blankImg blankTitle:(NSString *)blankTitle;
  45. //针对学习模块 - 删除所有数据之后再进行刷新
  46. - (void)removeAllDataToReload;
  47. @end
  48. @protocol GHRefreshTableViewDelegate <NSObject>
  49. @required
  50. /**
  51. 上拉加载和下拉刷新回调事件
  52. @param tableView 当前TableView
  53. @param pageIndex 加载页号(为0是即为下拉刷新)
  54. @param success 成功回调(传入当前页数据,页面将自动刷新)
  55. @param failure 失败回调(传入失败信息,页面将自动提示)
  56. */
  57. - (void)tableView:(GHRefreshTableView *)tableView
  58. pageIndex:(NSUInteger)pageIndex
  59. offset:(NSInteger)offset
  60. pageSize:(NSUInteger)pageSize
  61. success:(void (^)(NSArray * _Nullable list, BOOL hasNext))success
  62. failure:(void (^)(NSError *error))failure;
  63. @end
  64. NS_ASSUME_NONNULL_END