Commit cba18926 authored by 汪洋's avatar 汪洋

baselist开始使用行高自动计算

parent 2ffec84d
......@@ -26,7 +26,6 @@
[super initController];
_tableStyle = UITableViewStylePlain;
_cellIdentifier = @"";
_cellHeight = 0;
self.viewModel = [[WMFetchDataViewModel alloc] init];
_needHeaderRefresh = YES;
_needFooterRefresh = YES;
......@@ -41,12 +40,12 @@
_table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 0) style:_tableStyle];
_table.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
_table.separatorStyle = UITableViewCellSeparatorStyleNone;
_table.rowHeight = _cellHeight;
_table.delegate = self;
_table.dataSource = self;
_table.estimatedRowHeight = 0;
_table.estimatedSectionHeaderHeight = 0;
_table.estimatedSectionFooterHeight = 0;
_table.rowHeight = UITableViewAutomaticDimension;
_table.estimatedRowHeight = 80;
_table.sectionHeaderHeight = UITableViewAutomaticDimension;
_table.sectionFooterHeight = UITableViewAutomaticDimension;
// 如果_cellIdentifier 能转成一个UITableViewCell class,才去注册,否则会有crash发生
if ([NSClassFromString(_cellIdentifier) isSubclassOfClass:[UITableViewCell class]]) {
......@@ -123,21 +122,6 @@
[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView.rowHeight > 0) {
return tableView.rowHeight;
}else{
__weak __typeof(self)weakSelf = self;
NSAssert(_cellIdentifier.length > 0, @"WMBaseListViewController 中的tableView:heightForRowAtIndexPath 方法想使用 _cellIdentifier, 然而 _cellIdentifier 为空");
CGFloat height = [_table fd_heightForCellWithIdentifier:_cellIdentifier cacheByIndexPath:indexPath configuration:^(UITableViewCell *cell) {
[weakSelf configDataForCell:cell atIndexPath:indexPath];
}];
return height;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:_cellIdentifier forIndexPath:indexPath];
[self configDataForCell:cell atIndexPath:indexPath];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment