TMOTableView 1.1.3

TMOTableView 1.1.3

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2016年8月

PonyCui维护。



  • PonyCui

TMOTableView包括RefreshControl、LoadMoreControl、FirstLoadControl,您可以根据需要自定义它。它支持iOS5+,支持UIViewController & UITableViewController。

  • V1.1发布!我们重构了整个项目,使其更加易于阅读。我们还添加了一个演示,TMOEmptyDataSetDemo,它比DNZEmptyDataSet更易于使用。

使用方法

Pod

pod 'TMOTableView'

子类(必须做)

  • Xib 或 StoryBoard -> 将UITableView子类化到TMOTableView

  • 代码 -> 初始化TMOTableView


使用FirstLoadControl

  • 您使用FirstLoadControl以避免显示空内容,并提供良好的用户体验。我们提供一个默认的loadingView和一个默认的failView。此外,您可以自定义它。

  • 使用真的很简单,请参阅示例代码。


[self.tableView firstLoadWithBlock:^(TMOTableView *tableView, DemoTableViewController *viewController) {
    //do something load data jobs
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (arc4random() % 10 < 3) {
            //We try to make load data jobs fail, and you can see what happen.
            [tableView.myFirstLoadControl fail];
        }
        else {
            viewController.numberOfRowsInSection0 = 5;
            viewController.numberOfRowsInSection1 = 8;
            [tableView.myFirstLoadControl done];//You don't need to use [tableView reloadData].
        }
    });
} withLoadingView:customLoadingView withFailView:customFailView];

使用RefreshControl

  • RefreshControl,您已了解!我们的RefreshControl支持iOS5+

[self.tableView refreshWithCallback:^(TMOTableView *tableView, DemoTableViewController *viewController) {
    viewController.numberOfRowsInSection0 = arc4random() % 10;
    viewController.numberOfRowsInSection1 = arc4random() % 10;
    [tableView.myRefreshControl done];
} withDelay:1.5];//Really easy to use.
//Don't use self in block! Use tableView, viewController. It will 'Circular references'.

使用LoadMoreControl

  • 您可以使用LoadMoreControl来显示更多单元格。

[self.tableView loadMoreWithCallback:^(TMOTableView *tableView, DemoTableViewController *viewController) {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (arc4random() % 10 < 4) {
            //try to fail
            [tableView.myLoadMoreControl fail];
        }
        else {
            viewController.numberOfRowsInSection1 += 10;
            [tableView.myLoadMoreControl done];
        }
    });
} withDelay:0.0];