美文网首页
UITableViewPlaceholder ---UITabl

UITableViewPlaceholder ---UITabl

作者: 拾酥 | 来源:发表于2018-01-08 10:43 被阅读0次

UITableView 数据为空时候的提示占位图,主要应用于网络出现错误的时候、数据源为空的时候

演示图片

实现使用的是UITableView+category的方式,不需要额外的继承。

使用起来也很便捷,当前页面需要占位图的时候

    kWeak(self);
    self.tableView.defaultNoDataText = @"这是一行提示的文字呀";
    self.tableView.defaultNoDataViewDidClickBlock = ^(UIView *view) {
        kStrong(self);
        self.data = @[@"删除数据,显示默认提示",@"删除数据,显示自定义提示"];
        [self.tableView reloadData];
    };

支持更改默认的提示文字和图片

/// 设置默认的提示文字
@property (nonatomic, copy) NSString *defaultNoDataText;
/// 设置默认的提示图片
@property (nonatomic, strong) UIImage *defaultNoDataImage;

也支持使用自定义的提示图

tableView.customNoDataView = [self customNoticeView];

道理相通的,也可以给UICollectionView做这样一个扩展

https://github.com/tengshuq/TableViewPlaceholder
如果您觉得有帮助,GitHub上来个star吧~~

相关文章

网友评论

      本文标题:UITableViewPlaceholder ---UITabl

      本文链接:https://www.haomeiwen.com/subject/gkgvnxtx.html