JMOTableViewDescription 0.3.0

JMOTableViewDescription 0.3.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布最后发布2016年10月

Jérôme Morissard 维护。




  • jerome Morissard

我的其他作品

http://leverdeterre.github.io

目的

JMOTableViewDescription 是一个 Objective-C 库,可以轻松创建和管理复杂的 structured tableView。

Image

为什么这个项目?

  • TableView 协议很简单,但不适应于操作杂合对象或 TableView 中的 cells。
  • 某些情况会导致构建正确的 TableViewCell 来表示特定对象的非常复杂的算法。

本项目提供

  • 使用非常简单的方法(一个模型)来描述您的 tableView "布局"的新方式,
  • 使用此模型大大简化了数据源/代理的处理,
  • 这是一种不使用分组样式即可生成“分组 tableView”样式的方法!
  • 使用此实现生成的代码非常可定制、可重用和灵活。(不再有 bugs?)
  • TableView 代理和数据源专注于操作对象,无需 indexPath!
  • HeaderView 复用?用 cell 替换您的 headline,您的第一行 :)

支持的 iOS & SDK 版本

  • 支持的构建目标 - iOS 8 (Xcode 6 测试版)
  • 最早支持的部署目标 - iOS 6.0
  • 最早兼容的部署目标 - iOS 6.0

注意:'支持的' 意味着库已与本版本进行测试。'兼容的' 意味着库应该在该 iOS 版本上运行(即它不依赖任何不可用的 SDK 功能),但不再进行兼容性测试,可能需要调整或修复 bug 以正确运行。

版本

0.1,初始发布
0.2
  • 添加自动注册 cells 和 header/footer 视图的示例方法。
  • 添加具有通用实现的 UIViewControllers 以用于 UITableViewDatasource/delegate (JMOViewControllerWithTableViewDescription,JMOTableViewControllerWithTableViewDescription)。
  • 通过使用元素描述中的数据来更新 Cells、Footers、Headers 的协议(updateCellWithDescriptionData:(id)data && updateSectionWithDescriptionData:(id)data)。
  • 添加新的协议:JMOTableViewDescriptionDelegate,专注于数据而不是 indexPath。

如何使用它?

  • 实现自己的 JMODemoTableViewDescription,
JMODemoTableViewDescription *desc = [JMODemoTableViewDescription new];
JMOTableViewSectionDescription *oneSection = [JMOTableViewSectionDescription new];

JMOTableViewRowDescription *oneRow = [JMOTableViewRowDescription new];
oneRow.cellClass = [UITableViewCell class];
oneRow.cellHeight = 30.0f;
oneRow.cellReuseIdentifier = @"UITableViewCellIdentifier";
oneRow.data = @"My Fake 1st section (it's a cell!)";
[oneSection addRowDescription:oneRow];
...
return desc;
  • 实现常见的 cell/section 更新
@protocol JMOTableViewDescriptionCellUpdate <NSObject>

@optional
- (void)updateCellWithData:(id)data;
- (void)updateCellWithRowDescription:(id)data;

@end
  • 实现自己的 cell 更新来管理特殊情况
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];

    //You can manage your own custom update
    if (cell.class == UITableViewCell.class) {
        JMOTableViewRowDescription *rowDesc = [self.tableViewDescription rowDescriptionForIndexPath:indexPath];
        cell.textLabel.text = rowDesc.data;
    } 
    return cell;
}
  • 实现 JMOTableViewDescriptionDelegate,专注于数据
- (void)tableView:(UITableView *)tableView didSelectDataDescription:(id)selectedData
{
    JMOLog(@"Do something with selectedData : %@",selectedData);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TableViewDescriptionDelegate" message:@"Do something with selected Data" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
    [alert show];
}