MJRefreshBaseView.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // MJRefreshBaseView.h
  3. // MJRefresh
  4. //
  5. // Created by mj on 13-3-4.
  6. // Copyright (c) 2013年 itcast. All rights reserved.
  7. #import <UIKit/UIKit.h>
  8. /**
  9. 枚举
  10. */
  11. // 控件的刷新状态
  12. typedef enum {
  13. MJRefreshStatePulling = 1, // 松开就可以进行刷新的状态
  14. MJRefreshStateNormal = 2, // 普通状态
  15. MJRefreshStateRefreshing = 3, // 正在刷新中的状态
  16. MJRefreshStateWillRefreshing = 4
  17. } MJRefreshState;
  18. // 控件的类型
  19. typedef enum {
  20. MJRefreshViewTypeHeader = -1, // 头部控件
  21. MJRefreshViewTypeFooter = 1 // 尾部控件
  22. } MJRefreshViewType;
  23. @class MJRefreshBaseView;
  24. /**
  25. 回调的Block定义
  26. */
  27. // 开始进入刷新状态就会调用
  28. typedef void (^BeginRefreshingBlock)(MJRefreshBaseView *refreshView);
  29. // 刷新完毕就会调用
  30. typedef void (^EndRefreshingBlock)(MJRefreshBaseView *refreshView);
  31. // 刷新状态变更就会调用
  32. typedef void (^RefreshStateChangeBlock)(MJRefreshBaseView *refreshView, MJRefreshState state);
  33. /**
  34. 代理的协议定义
  35. */
  36. @protocol MJRefreshBaseViewDelegate <NSObject>
  37. @optional
  38. // 开始进入刷新状态就会调用
  39. - (void)refreshViewBeginRefreshing:(MJRefreshBaseView *)refreshView;
  40. // 刷新完毕就会调用
  41. - (void)refreshViewEndRefreshing:(MJRefreshBaseView *)refreshView;
  42. // 刷新状态变更就会调用
  43. - (void)refreshView:(MJRefreshBaseView *)refreshView stateChange:(MJRefreshState)state;
  44. @end
  45. /**
  46. 类的声明
  47. */
  48. @interface MJRefreshBaseView : UIView
  49. {
  50. // 父控件一开始的contentInset
  51. UIEdgeInsets _scrollViewInitInset;
  52. // 父控件
  53. __weak UIScrollView *_scrollView;
  54. // 子控件
  55. __weak UILabel *_lastUpdateTimeLabel;
  56. __weak UILabel *_statusLabel;
  57. __weak UIImageView *_arrowImage;
  58. __weak UIActivityIndicatorView *_activityView;
  59. // 状态
  60. MJRefreshState _state;
  61. }
  62. //@property (nonatomic,weak) UILabel *_statusLabel;
  63. // 构造方法
  64. - (instancetype)initWithScrollView:(UIScrollView *)scrollView;
  65. // 设置要显示的父控件
  66. @property (nonatomic, weak) UIScrollView *scrollView;
  67. // 内部的控件
  68. @property (nonatomic, weak, readonly) UILabel *lastUpdateTimeLabel;
  69. @property (nonatomic, weak) UILabel *statusLabel;
  70. @property (nonatomic, weak, readonly) UIImageView *arrowImage;
  71. // Block回调
  72. /// <#Description#>
  73. @property (nonatomic, copy) BeginRefreshingBlock beginRefreshingBlock;
  74. @property (nonatomic, copy) RefreshStateChangeBlock refreshStateChangeBlock;
  75. @property (nonatomic, copy) EndRefreshingBlock endStateChangeBlock;
  76. // 代理
  77. @property (nonatomic, weak) id<MJRefreshBaseViewDelegate> delegate;
  78. // 是否正在刷新
  79. @property (nonatomic, readonly, getter=isRefreshing) BOOL refreshing;
  80. // 开始刷新
  81. - (void)beginRefreshing;
  82. // 结束刷新
  83. - (void)endRefreshing;
  84. // 不静止地结束刷新
  85. //- (void)endRefreshingWithoutIdle;
  86. // 结束使用、释放资源
  87. - (void)free;
  88. /**
  89. 交给子类去实现 和 调用
  90. */
  91. - (void)setState:(MJRefreshState)state;
  92. - (int)totalDataCountInScrollView;
  93. @end