You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
180 lines
5.4 KiB
180 lines
5.4 KiB
// |
|
// TFCoveragePageTurningController.h |
|
// TFReader |
|
// |
|
// Created by 谢腾飞 on 2020/12/21. |
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved. |
|
// |
|
|
|
#import <UIKit/UIKit.h> |
|
|
|
NS_ASSUME_NONNULL_BEGIN |
|
|
|
@class TFCoveragePageTurningController; |
|
|
|
typedef NS_ENUM(NSUInteger ,TFPageRollingDirection) { |
|
TFPageRollingDirectionNone = 0, // 未知状态 |
|
TFPageRollingDirectionLeft = 1, // 上一页 |
|
TFPageRollingDirectionRight = 2 // 下一页 |
|
}; |
|
|
|
// 注意:!!!!!!!!!!!!!! |
|
// 在以下所有提供的方法中 包含View和Controller的方法只需要实现其中之一就可以了 |
|
// 比如:contentModeController = YES (默认)只需要实现所有的Controller方法即可 |
|
// contentModeController = NO (可自己根据实际需求设置)只需要实现所有的View方法即可 |
|
// 控件支持数据源分段加载 比如小说阅读时 可以先加载一部分展示后计算准确页数在reload |
|
|
|
/** |
|
TFCoveragePageTurningController 数据源代理 |
|
*/ |
|
@protocol TFCoveragePageTurningControllerDataSource <NSObject> |
|
@required |
|
|
|
/** |
|
总页数 |
|
|
|
@param pageController pageController |
|
@return 总页数 |
|
*/ |
|
- (NSInteger)numberOfPagesInPageController:(nonnull TFCoveragePageTurningController *)pageController; |
|
|
|
@optional |
|
|
|
/** |
|
将要展示页需要的内容 contentModeController = YES |
|
|
|
@param pageController pageController |
|
@param index 将要展示页的索引 |
|
@return 展示内容的控制器 |
|
*/ |
|
- (nullable UIViewController *)pageController:(nonnull TFCoveragePageTurningController *)pageController controllerForIndex:(NSInteger)index; |
|
|
|
/** |
|
将要展示页需要的内容 contentModeController = NO |
|
|
|
@param pageController pageController |
|
@param index 将要展示页的索引 |
|
@return 展示内容的视图 |
|
*/ |
|
- (nullable UIView *)pageController:(nonnull TFCoveragePageTurningController *)pageController viewForIndex:(NSInteger)index direction:(TFPageRollingDirection)rollingDirection; |
|
|
|
@end |
|
|
|
|
|
/** |
|
TFCoveragePageTurningController 控制交互代理 |
|
*/ |
|
@protocol TFCoveragePageTurningControllerDelegate <NSObject> |
|
|
|
@optional |
|
|
|
/** |
|
当前显示的Controller |
|
|
|
@param pageController pageController |
|
@param currentController 当前显示的Controller |
|
@param currentIndex 当前页面的索引 |
|
*/ |
|
- (void)pageController:(nonnull TFCoveragePageTurningController *)pageController currentController:(nullable UIViewController *)currentController currentIndex:(NSInteger)currentIndex; |
|
|
|
/** |
|
当前显示的View |
|
|
|
@param pageController pageController |
|
@param currentView 当前显示的View |
|
@param currentIndex 当前页面的索引 |
|
*/ |
|
- (void)pageController:(nonnull TFCoveragePageTurningController *)pageController currentView:(nullable UIView *)currentView currentIndex:(NSInteger)currentIndex direction:(TFPageRollingDirection)rollingDirection; |
|
|
|
|
|
/** |
|
已切换到第一页 |
|
|
|
@param pageController pageController |
|
*/ |
|
- (void)pageControllerDidSwitchToFirst:(nonnull TFCoveragePageTurningController *)pageController; |
|
|
|
/** |
|
已切换到最后一页 |
|
|
|
@param pageController pageController |
|
*/ |
|
- (void)pageControllerDidSwitchToLast:(nonnull TFCoveragePageTurningController *)pageController; |
|
|
|
/** |
|
控制器不能切换到上一页 |
|
|
|
@param pageController pageController |
|
*/ |
|
- (void)pageControllerSwitchToLastDisabled:(nonnull TFCoveragePageTurningController *)pageController; |
|
|
|
/** |
|
控制器不能切换到上一页 |
|
|
|
@param pageController pageController |
|
*/ |
|
- (void)pageControllerSwitchToNextDisabled:(nonnull TFCoveragePageTurningController *)pageController; |
|
|
|
@end |
|
|
|
|
|
@interface TFCoveragePageTurningController : UIViewController |
|
/*! 数据源代理 */ |
|
@property(nonatomic ,weak ,nullable) id<TFCoveragePageTurningControllerDataSource> dataSource; |
|
/*! 代理 */ |
|
@property(nonatomic ,weak ,nullable) id<TFCoveragePageTurningControllerDelegate> delegate; |
|
/*! Controller内容模式 default YES / View内容模式 NO */ |
|
@property(nonatomic) BOOL contentModeController; |
|
/*! 动画开启状态 default:YES */ |
|
@property(nonatomic) BOOL switchAnimated; |
|
/*! 滑动切换启用状态 default:YES */ |
|
@property(nonatomic) BOOL switchSlideEnabled; |
|
/*! 单击切换启用状态 default:YES */ |
|
@property(nonatomic) BOOL switchTapEnabled; |
|
/*! 循环切换启用状态 default:YES */ |
|
@property(nonatomic) BOOL circleSwitchEnabled; |
|
/*! 上一页切换启用状态 default:YES */ |
|
@property(nonatomic) BOOL switchToLastEnabled; |
|
/*! 下一页切换启用状态 default:YES */ |
|
@property(nonatomic) BOOL switchToNextEnabled; |
|
/*! 当前控制器 */ |
|
@property(nonatomic ,strong ,readonly ,nullable) UIViewController *currentController; |
|
/*! 当前显示的View */ |
|
@property(nonatomic ,strong ,readonly ,nullable) UIView *currentView; |
|
/*! 是否正在动画中 */ |
|
@property(nonatomic ,readonly) BOOL isAnimating; |
|
|
|
|
|
#pragma mark - Method |
|
|
|
/** |
|
数据源刷新 |
|
在 (currentIndex != 0 && currentIndex < numberOfPages) 时此方法可以追加总页数而不影响当前页以前的内容 |
|
否则 此方法强制刷新到第一页 |
|
*/ |
|
- (void)reloadData; |
|
|
|
/** |
|
数据源刷新 此方法强制刷新到第一页 |
|
*/ |
|
- (void)reloadDataToFirst; |
|
|
|
/** |
|
判断能否切换到某一页 |
|
|
|
@param index 某一页索引 |
|
@return BOOL结果 |
|
*/ |
|
- (BOOL)canSwitchToIndex:(NSInteger)index; |
|
|
|
/** |
|
切换到某一页 需要先做判断 即先调用canSwitchToIndex:index 否则可能发生崩溃 |
|
|
|
@param index 某一页索引 |
|
@param animated 是否需要动画效果 |
|
*/ |
|
- (void)switchToIndex:(NSInteger)index animated:(BOOL)animated; |
|
|
|
@end |
|
|
|
NS_ASSUME_NONNULL_END
|
|
|