CocoaPods trunk is moving to be read-only. Read more on the blog, there are 8 months to go.

KLTableViewAndCollectionViewPlaceholder 0.1.1

KLTableViewAndCollectionViewPlaceholder 0.1.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2017

Maintained by kelei.



  • By
  • 柯磊

CYLTableViewPlaceHolder 启发,将更新数据的方法尽可能的封装(不只是reload),使得不用修改现有代码,及可非常容易的实现UITableViewUICollectionView的“无数据”提示,零成本。

相比CYLTableViewPlaceHolder优点:

  • 不用修改reload
  • 支持更多刷新数据方法。如:insertSections:deleteSections:insertRowsAtIndexPaths:等等
  • 使用Auto Layout设置placeholderView位置,更准确,且支持横竖屏切换
  • 可随时取消placeholderView逻辑([self.tableView kl_placeholderViewBlock:nil];)
  • 支持UICollectionView

使用

CocoaPod

pod 'KLTableViewAndCollectionViewPlaceholder'

Objective-C

[self.tableView kl_placeholderViewBlock:^UIView * _Nonnull(UITableView * _Nonnull tableView) {
    // 这里做空数据操作,例如弹出提示

    // 禁止 TableView 滚动
    tableView.scrollEnabled = NO;
    // 返回无数据提示视图
    return placeholderView;
} backToNormalBlock:^(UITableView * _Nonnull tableView) {
    // 这里做恢复操作

    // 恢复 TableView 滚动
    tableView.scrollEnabled = YES;
}];

Swift

tableView.kl_placeholderViewBlock({ (tableView) -> UIView in
    tableView.isScrollEnabled = false
    return placeholderView
}, backToNormalBlock: { (tableView) in
    tableView.isScrollEnabled = true
})

适用场景

License

Centipede is released under the MIT license. See LICENSE for details.