Code Monkey home page Code Monkey logo

zdtableviewbinding's Introduction

License Platform Language

ZDTableViewBinding

简介:

ZDTableViewBinding是利用ReactiveCocoa自动分发tableView的数据并计算高度且缓存的工具,支持headerfooter

ZDTableViewBinding 用法:

主要的就一个实例方法和一个类方法

+ (instancetype)bindingHelperForTableView:(__kindof UITableView *)tableView
                             multiSection:(BOOL)multiSection
                         dataSourceSignal:(__kindof RACSignal *)dataSourceSignal
                              cellCommand:(nullable RACCommand *)cellCommand
                      headerFooterCommand:(nullable RACCommand *)headerFooterCommand

传参数之前,需要把cellsection包装成cellViewModelsectionViewModel,监听 source 数据,然后把sourceSignal扔给ZDTableViewBindingHelper,剩下的事情就不用管了。

cell 和 section 中的控件的响应事件会通过外面的command进行操作,比如,当footer上的button被点击时,执行RACCommandexecute:方法。

- (IBAction)bottomButtonAction:(UIButton *)sender
{
    NSLog(@"tap footer button");
    [self.headerFooterCommand execute:RACTuplePack(sender, self.sectionModel)];
}

然后bindingHelper的对应的command执行,你可以在tuple中参数设置指定的 key 来判断到底是哪个控件传过来的事件,然后再进行对应的处理操作。

如果想单独执行tableViewDelegate的某个方法,则需要设置delegate,并实现相关协议。


Installation with CocoaPods

Add the following line to your Podfile.

pod 'ZDTableViewBinding'

Then, run the following command:

$ pod install

License

ZDTableViewBinding is under an MIT license. See the LICENSE file for more information.

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.