JVRCellConfiguratorDelegate 1.0.2

JVRCellConfiguratorDelegate 1.0.2

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最后发布2014年12月

József Vesza 维护。



一个协议,用于负责创建和配置 UICollectionViewCellUITableViewCell 对象的类。这个类是用来和我的 JVRCollectionViewDataSourceJVRBaseTableViewDataSource 项目一起使用的

配置单元

单元配置类旨在封装以前在 UITableViewDataSource/UICollectionViewDataSource 协议中找到的 tableView:cellForRowAtIndexPath:/collectionView:cellForItemAtIndexPath: 方法中的逻辑。可以使用它们来根据对象返回单元格的重用标识符,并自定义其外观或行为。以下示例展示了表格视图单元的可能实现,但这种过程也可以用于集合视图。

// MyCellConfigurator.h
#import "JVRCellConfiguratorDelegate.h"

@interface MyCellConfigurator : NSObject<JVRCellConfiguratorDelegate>
@end

// MyCellConfigurator.m
@implementation MyCellConfigurator

- (NSString *)fetchCellIdentifierForObject:(id)anObject
{
    if ([anObject isKindOfClass:[MyClass class]])
    {
        return @"myCell";
    }

    return @"regularCell";
}

- (UITableViewCell *)configureCell:(MyCell *)cell usingObject:(MyClass *)object
{
    cell.titleLabel.text = object.stringProperty;
    return cell;
}

@end

安装

如果您正在使用 JVRCollectionViewDataSourceJVRBaseTableViewDataSource 并与 CocoaPods 一起使用,则 JVRCellConfiguratorDelegate 也作为依赖项下载。您可以单独包含它,方法是将源文件添加到您的项目或将其添加到 Podfile 中

pod 'JVRCellConfiguratorDelegate'