测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布时间最后发布时间 | 2016年4月 |
SPM支持 SPM | ✗ |
由 Ritesh 维护。
PullToRefreshPaginationManager 允许您通过几行代码就实现 刷新(下拉刷新)和 分页(加载更多)功能。它可以与 UIScrollView
或其子类(如 UITableView
和 UICollectionView
)一起使用。有 2 种使用方法:
它提供默认的刷新和分页管理器(垂直和水平),您可以使用它快速实现网络请求的处理,这也可以用于支持复杂的刷新或分页 UI 动画。
let refreshManager = PullToRefreshManager(scrollView: self.scrollView, delegate: self)
let paginatioManager = PaginationManager(scrollView: self.scrollView, delegate: self)
let horizontalPaginationManager = HorizontalPaginationManager(scrollView: self.scrollView, delegate: self)
通过简单地定义 ScrollViewStateControllerDataSource
方法来定义它们的功能,您可以快速编写自己的自定义刷新和分页管理器。想了解更多信息,您可以查看我是如何制作默认管理器的。
要在 Xcode 项目中使用 CocoaPods 集成 PullToRefreshPaginationManager,请在 Podfile 中指定它。
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'PullToRefreshPaginationManager', :git => 'https://github.com/riteshhgupta/PullToRefreshPaginationManager.git', :branch => 'master'
有 2 种使用方法:
默认管理器可以让您通过几行代码就实现以下功能,并提供了其委托方法,以便进行 API 调用或动画化的自定义加载器。
let refreshManager = PullToRefreshManager(scrollView: self.scrollView, delegate: self)
// delegate method
func refreshManagerDidStartLoading(controller: PullToRefreshManager, onCompletion: CompletionHandler)
let paginatioManager = PaginationManager(scrollView: self.scrollView, delegate: self)
// delegate method
func paginationManagerDidStartLoading(controller: PaginationManager, onCompletion: CompletionHandler)
func paginationManagerShouldStartLoading(controller: PaginationManager) -> Bool
let horizontalPaginationManager = HorizontalPaginationManager(scrollView: self.scrollView, delegate: self)
// delegate method
func horizontalPaginationManagerDidStartLoading(controller: HorizontalPaginationManager, onCompletion: CompletionHandler)
除了默认管理器之外,如果您觉得需要更多定制化,则可以直接实现以下 ScrollViewStateControllerDataSource
方法来定义您在控制器中或任何管理器类中定义的各种自定义条件。
// it defines the condition whether to use y or x point for content offset
func stateControllerWillObserveVerticalScrolling() -> Bool
// it defines the condition when to enter the loading zone
func stateControllerShouldInitiateLoading(offset: CGFloat) -> Bool
// it defines the condition when the loader stablises (after releasing) and loading can start
func stateControllerDidReleaseToStartLoading(offset: CGFloat) -> Bool
// it defines the condition when to cancel loading
func stateControllerDidReleaseToCancelLoading(offset: CGFloat) -> Bool
// it will return the loader frame
func stateControllerLoaderFrame() -> CGRect
// it will return the loader inset
func stateControllerInsertLoaderInsets(startAnimation: Bool) -> UIEdgeInsets
它提供了以下 ScrollViewStateControllerDelegate
方法来处理 API 调用和自定义加载器动画。
// it gets called continously till your loading starts
func stateControllerWillStartLoading(controller: ScrollViewStateController, loadingView: UIActivityIndicatorView)
// it allows you to decide if you want loading action
func stateControllerShouldStartLoading(controller: ScrollViewStateController) -> Bool
// it gets called once when loading actually starts
func stateControllerDidStartLoading(controller: ScrollViewStateController, onCompletion: CompletionHandler)
//it gets called when loading is finished
func stateControllerDidFinishLoading(controller: ScrollViewStateController)
在此处打开问题或发送拉取请求 这里。