Giter Site home page Giter Site logo

londonxue / tmotableview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cherishloveyou/tmotableview

0.0 2.0 0.0 792 KB

TMOTableView includes RefreshControl LoadMoreControl FirstLoadControl, and you can customize it. It support iOS5+, support UIViewController & UITableViewController.

Home Page: http://www.duowan.com

License: MIT License

Ruby 1.39% Objective-C 98.61%

tmotableview's Introduction

TMOTableView

TMOTableView includes RefreshControl LoadMoreControl FirstLoadControl, and you can customize it. It support iOS5+, support UIViewController & UITableViewController.

  • V1.1 Released! We reconstruct whole project, make it much more readable. And we add one more demo, TMOEmptyDataSetDemo, it's really easy to use rather than DNZEmptyDataSet.

Usage

Pod

pod 'TMOTableView'

Subclass(Must Do)

  • Xib Or StoryBoard -> subclass UITableView To TMOTableView

  • Code -> Init TMOTableView


Use FirstLoadControl

  • 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];

Use RefreshControl

  • RefreshControl, you know that! Our RefreshControl support 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'.

Use LoadMoreControl

  • You use LoadMoreControl to show more cells.

[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];

tmotableview's People

Contributors

ponycui avatar xhzengaib avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.