EPSCommandCell 0.1.2

EPSCommandCell 0.1.2

测试已测试
语言语言 Objective-CObjective C
许可证 MIT
发布上次发布2014年12月

Peter Stuart 维护。



  • Peter Stuart

EPSCommandCellUITableViewCell的一个子类,具有command属性

@property (nonatomic) RACCommand *command;

command被启用时,单元格的文本颜色设置为当前的自定义颜色(默认为蓝色)。当command被禁用时,单元格的文本为灰色。

用法

使用一个命令来设置单元格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    EPSCommandCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    cell.textLabel.text = "Some Text";
    cell.command = self.someCommand;
    return cell;
}

确保当其命令被禁用时,单元格不能被点击

- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    EPSCommandCell *cell = (EPSCommandCell *)[tableView cellForRowAtIndexPath:indexPath];
    return cell.canExecuteCommand;
}

当单元格被点击时,执行其命令

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    EPSCommandCell *cell = (EPSCommandCell *)[tableView cellForRowAtIndexPath:indexPath];
    [cell.command execute:nil];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

安装

EPSCommandCell可通过CocoaPods访问。要安装它,请简单地将以下行添加到您的Podfile中:

pod "EPSCommandCell"

许可证

EPSCommandCell在MIT许可证下提供。有关更多信息,请参阅LICENSE文件。