TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Aug 2016 |
Maintained by PonyCui.
TMOTableView includes RefreshControl LoadMoreControl FirstLoadControl, and you can customize it. It support iOS5+, support UIViewController & UITableViewController.
pod 'TMOTableView'
Xib Or StoryBoard -> subclass UITableView To TMOTableView
Code -> Init TMOTableView
You use FirstLoadControl to avoid null content showed, and perform good user experience. We provide a default loadingView, and we provide a default failView. Further more, you could custom it.
It's really easy to use, see example code.
[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];
[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'.
[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];