对 tableview 的扩展,通过数据源控制和显示,无需实现一行委托类,当然,您也可以根据自己的喜好使用委托类来实现。tableview 使用最多,对 tableview 的玩法是对表视图的数据结构操作。设计理念:程序由算法和数据结构组成,那么算法只负责逻辑,所有可能来源都有数据结构提供。
该方法支持在数据中添加 tableview 的选择事件,默认的 cell 样式、accessoryView、block 等等!
如果您有好的建议,请联系我:[email protected],其实自己仔细琢磨更有意思!
简单使用:`pod 'tableivewSimplify'`
示例
self.tableView.itemsArray = @[
@"第一条",
@"第二条",
@"第3条",
@"第4条",
@"第5条",
@"第6条",
@"第7条",
@"第8条",
@"第9条",
@"第10条",
@"第11条"
].mutableCopy;
self.secondTableView.keyForTitleView = @"title";
self.secondTableView.itemsArray = @[
@{
@"title" : @"第一"
},
@{
@"title" : @"第二"
},
@{
@"title" : @"第仨"
}
].mutableCopy;
self.thirdTableView.keyOfHeadTitle = @"title";
//可以不配置 有默认值
self.thirdTableView.keyForTitleView = @"title";
self.thirdTableView.keyForDetailView = @"detail";
self.thirdTableView.keyOfItemArray = @"items";
self.thirdTableView.sectionable = YES;
self.thirdTableView.tableViewCellClass = [HsBaseTableViewCellStyleValue1 class];
self.thirdTableView.itemsArray = @[
@{
@"title" : @"人",
@"items" : @[
@{
@"title" : @"美女",
@"detail" : @"很漂亮"
},
@{
@"title" : @"帅哥",
@"detail" : @"大长腿"
}
]
},
@{
@"title" : @"第二",
@"items" : @[
@{
@"title" : @"美女",
@"detail" : @"很漂亮"
},
@{
@"title" : @"帅哥",
@"detail" : @"大长腿"
}
]
},
@{
@"title" : @"第仨",
@"items" : @[
@{
@"title" : @"美女",
@"detail" : @"很漂亮"
},
@{
@"title" : @"帅哥",
@"detail" : @"大长腿"
}
]
}
].mutableCopy;
__weak UIViewController *weakSelf = self;
self.forthTableView.keyOfHeadTitle = @"title";
self.forthTableView.autoLayout = YES;
self.forthTableView.sectionable = YES;
self.forthTableView.baseDataSource = self;
self.forthTableView.tableViewCellArray = @[
[UINib nibWithNibName:@"TableViewDemoCell" bundle:nil],
[HsBaseTableViewCellStyleValue1 class]
];
self.forthTableView.itemsArray = @[
@{
@"title" : @"人",
@"items" : @[
[User user:@"张三1" sex:@"男"],
[User user:@"张三2" sex:@"男"]
]
},
@{
@"title" : @"第二",
@"items" : @[
@{
@"title" : @"美女",
@"detail" : @"很漂亮",
HsCellKeySelectedBlock : ^(NSIndexPath *indexPath){
[weakSelf.navigationController pushViewController:[[HsRefreshTableViewController alloc] init] animated:YES];
NSLog(@"选中第%ld行",indexPath.row);
},
HsBaseTableViewKeyTypeForRow : @(1)//等同于下面的typeForRowAtIndexPath委托方法
},
@{
@"title" : @"美女",
@"detail" : @"很漂亮",
HsBaseTableViewKeyTypeForRow : @(1)//等同于下面的typeForRowAtIndexPath委托方法
}
]
},
@{
@"title" : @"第仨",
@"items" : @[
[User user:@"张三5" sex:@"女"],
[User user:@"张三6" sex:@"男"]
]
}
].mutableCopy;