ZDTableViewBinding 0.3.2

ZDTableViewBinding 0.3.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2019

Maintained by faimin.



  • By
  • Zero.D.Saber

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.