JXPagerSmoothView.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // JXPagerSmoothView.h
  3. // JXPagerViewExample-OC
  4. //
  5. // Created by jiaxin on 2019/11/15.
  6. // Copyright © 2019 jiaxin. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class JXPagerSmoothView;
  10. @protocol JXPagerSmoothViewListViewDelegate <NSObject>
  11. /**
  12. 返回listView。如果是vc包裹的就是vc.view;如果是自定义view包裹的,就是自定义view自己。
  13. */
  14. - (UIView *)listView;
  15. /**
  16. 返回JXPagerSmoothViewListViewDelegate内部持有的UIScrollView或UITableView或UICollectionView
  17. */
  18. - (UIScrollView *)listScrollView;
  19. @optional
  20. - (void)listDidAppear;
  21. - (void)listDidDisappear;
  22. @end
  23. @protocol JXPagerSmoothViewDataSource <NSObject>
  24. /**
  25. 返回页面header的高度
  26. */
  27. - (CGFloat)heightForPagerHeaderInPagerView:(JXPagerSmoothView *)pagerView;
  28. /**
  29. 返回页面header视图
  30. */
  31. - (UIView *)viewForPagerHeaderInPagerView:(JXPagerSmoothView *)pagerView;
  32. /**
  33. 返回悬浮视图的高度
  34. */
  35. - (CGFloat)heightForPinHeaderInPagerView:(JXPagerSmoothView *)pagerView;
  36. /**
  37. 返回悬浮视图
  38. */
  39. - (UIView *)viewForPinHeaderInPagerView:(JXPagerSmoothView *)pagerView;
  40. /**
  41. 返回列表的数量
  42. */
  43. - (NSInteger)numberOfListsInPagerView:(JXPagerSmoothView *)pagerView;
  44. /**
  45. 根据index初始化一个对应列表实例,需要是遵从`JXPagerSmoothViewListViewDelegate`协议的对象。
  46. 如果列表是用自定义UIView封装的,就让自定义UIView遵从`JXPagerSmoothViewListViewDelegate`协议,该方法返回自定义UIView即可。
  47. 如果列表是用自定义UIViewController封装的,就让自定义UIViewController遵从`JXPagerSmoothViewListViewDelegate`协议,该方法返回自定义UIViewController即可。
  48. @param pagerView pagerView description
  49. @param index index description
  50. @return 新生成的列表实例
  51. */
  52. - (id<JXPagerSmoothViewListViewDelegate>)pagerView:(JXPagerSmoothView *)pagerView initListAtIndex:(NSInteger)index;
  53. @end
  54. @protocol JXPagerSmoothViewDelegate <NSObject>
  55. - (void)pagerSmoothViewDidScroll:(UIScrollView *)scrollView;
  56. @end
  57. @interface JXPagerSmoothView : UIView
  58. /**
  59. 当前已经加载过的列表:key就是@(index)值,value是对应的列表。
  60. */
  61. @property (nonatomic, strong, readonly) NSDictionary <NSNumber *, id<JXPagerSmoothViewListViewDelegate>> *listDict;
  62. @property (nonatomic, strong, readonly) UICollectionView *listCollectionView;
  63. @property (nonatomic, assign) NSInteger defaultSelectedIndex;
  64. @property (nonatomic, weak) id<JXPagerSmoothViewDelegate> delegate;
  65. - (instancetype)initWithDataSource:(id<JXPagerSmoothViewDataSource>)dataSource NS_DESIGNATED_INITIALIZER;
  66. - (instancetype)init NS_UNAVAILABLE;
  67. - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
  68. - (instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;
  69. - (void)reloadData;
  70. @end