IDTableModuleCore
基于 UITableView 的简单模块配置。
入门
无需解释,查看示例即可
承包商
@class MyViewModel;
@interface MyContractor : IDMVVMTableContractor <IDMVVMTableContractorProtocol>
@property (nonatomic, weak) MyViewModel *viewModel;
@end
/* */
@implementation MyContractor
#pragma mark - Override
- (UITableViewRowAnimation)insertAnimation {
return UITableViewRowAnimationFade;
}
- (UITableViewRowAnimation)deleteAnimation {
return UITableViewRowAnimationFade;
}
- (void)bindCellViewModels {
[self rac_liftSelector:@selector(scrollToRowWithIndexPath:) withSignals:RACObserve(self.viewModel, nonValidIndexPath), nil];
[self rac_liftSelector:@selector(handleIncomingSectionViewModels:) withSignals:RACObserve(self.viewModel, sectionViewModels), nil];
}
#pragma mark - TableViewDelegate methods
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = (NSUInteger)indexPath.row;
NSUInteger section = (NSUInteger)indexPath.section;
id<IDCellViewModelProtocol> cellViewModel = self.viewModel.sectionViewModels[section].cellViewModels[row];
IDTableViewCell *cell = [super tableView:tableView
cellForRowAtIndexPath:indexPath
withIdentifier:cellViewModel.uniqueCellIdentifier
viewModel:cellViewModel];
return cell;
}
#pragma mark - TableViewDataSource methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.viewModel.sectionViewModels.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.viewModel.sectionViewModels[section].cellViewModels.count;
}
@end
示例
要运行示例项目,请先克隆存储库,然后运行 pod install --project-directory=Example
使用 CocoaPods 安装
CocoaPods 是一个 Objective-C 的依赖管理器,它自动并简化了在项目中使用像 IDTableModuleCore 这样的第三方库的过程。您可以使用以下命令安装它:
$ gem install cocoapods
Podfile
使用CocoaPods将IDTableModuleCore集成到您的Xcode项目中,请在您的Podfile
中指定它
platform :ios, '9.3'
use_frameworks!
target 'TargetName' do
pod 'IDTableModuleCore'
end
然后,运行以下命令
$ pod install
Requirements
最低的iOS目标版本是ios 9.0。
Licence
IDTableModuleCore采用MIT许可证发布。有关详情,请参阅LICENSE。
作者
Andrey Bronnikov,[email protected]