测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2016年10月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Gabriel Massana 维护。
控制数据状态的 Table View。
表格视图将自动控制视图的可见性。
platform :ios, '8.0'
use_frameworks!
pod 'TableViewDataStatus', '~> 1.0'
然后,运行以下命令
$ pod install
将文件夹 /TableViewDataStatus-iOS
拖入到您的项目中。就这样。
在示例中,空视图是一个简单的 UIView,背景为 orangeColor()。加载视图与之相同,但背景为 greenColor()。
在实际应用中,它们可以是任何带有任何元素的 UIView 子视图。
/**
Empty View to be shown when no data in the Table View.
*/
lazy var emptyView: UIView = {
let emptyView: UIView = UIView(frame: CGRect.init(x: 0.0, y: 0.0, width: CGRectGetWidth(UIScreen.mainScreen().bounds), height: CGRectGetHeight(UIScreen.mainScreen().bounds)))
emptyView.backgroundColor = UIColor.orangeColor()
return emptyView
}()
/**
Empty View to be shown when no data in the Table View.
*/
lazy var loadingView: UIView = {
let loadingView: UIView = UIView(frame: CGRect.init(x: 0.0, y: 0.0, width: CGRectGetWidth(UIScreen.mainScreen().bounds), height: CGRectGetHeight(UIScreen.mainScreen().bounds)))
loadingView.backgroundColor = UIColor.greenColor()
return loadingView
}()
/**
Table view to display data.
*/
lazy var tableView: TableViewDataStatus = {
let tableView: TableViewDataStatus = TableViewDataStatus.init(frame: UIScreen.mainScreen().bounds, style: .Plain)
tableView.emptyView = self.emptyView
tableView.loadingView = self.loadingView
return tableView
}()
/**
Fake API call method.
At the begining of the method willLoadContent() is called to update the loadingView visibility.
At the end of the APi call didFinishLoadingContent() is called to update again the views visibilities.
*/
func fakeAPICallAndComplition() {
// Call this method before the API call.
tableView.willLoadContent()
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(5.0 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
// Call this method on finish the API call.
self.tableView.didFinishLoadingContent(false)
}
}
#import "TableViewDataStatus-Swift.h"
TableViewDataStatus-iOS 在 MIT 许可证下发布。请参阅名为 LICENSE 的文件。
$ git tag -a 1.0.0 -m 'Version 1.0.0'
$ git push --tags
Gabriel Massana
如果您遇到TableViewDataStatus-iOS的特定问题,有功能请求或想要分享评论,请在以下地方打开一个新问题。