测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | MIT |
发布最新发布 | 2017年4月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Felipe Antonio Cardoso 维护。
UILoadControl 受 UIRefreshControl
的启发。它可以用于表示 UITableView
或 UICollectionView
底部的数据加载。
查看以下示例
默认情况下,UIControl
可以作为 UITableView
的子视图放置,并自动处理为 UIRefreshControl
并放置在其顶部。
UILoadControl
是 UIControl
的子类,放置在 UIView
(loadControlView
) 中,该视图作为 UIScrollView
的子视图。UILoadControl
有一个 UIScrollView
扩展 (UIScrollView_Extesnion
) 用于管理 UILoadControl
的布局。
所有 UIScrollView
都在其 .loadControl
属性中具有处理 UILoadControl
的能力。
要运行示例项目,请克隆仓库,然后从 Example 目录运行 pod install
。
像下面的例子一样,将 UILoadControl
添加到您想要的任何 UIScrollView
import UILoadControl
class MyViewController: UIViewController, UIScrollViewDelegate {
var tableView: UITableView!
//Setup loadControl on tableView
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.loadControl = UILoadControl(target: self, action: #selector(loadMore(sender:)))
tableView.loadControl?.heightLimit = 100.0 //The default is 80.0
}
//update loadControl when user scrolls de tableView
func scrollViewDidScroll(_ scrollView: UIScrollView) {
scrollView.loadControl?.update()
}
//load more tableView data
func loadMore(sender: AnyObject?) {
AnyAPIManager.defaultManager.giveMoreData() { (response, error) in
//... Manage response
self.tableView.loadControl?.endLoading() //Update UILoadControl frame to the new UIScrollView bottom.
self.tableView.reloadData()
}
}
}
就这样!
XCode 7.0,iOS 8.0,Swift 3
UILoadControl 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod "UILoadControl"
请随时提交拉取请求。
Felipe Antonio Cardoso, [email protected]
UILoadControl 在 MIT 许可下可用。更多信息见 LICENSE 文件。