Просмотр исходного кода

Redant Mobile
Common editor 自定义 table header view
search,searchsetting,result 增加title

Ray Zhang 8 лет назад
Родитель
Сommit
a2dce5c580
1 измененных файлов с 23 добавлено и 2 удалено
  1. 23 2
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

+ 23 - 2
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -66,11 +66,32 @@
 
 @implementation CommonEditorViewController
 
+
+- (void)viewDidLayoutSubviews {
+    [super viewDidLayoutSubviews];
+    [self resize_tableHeader];
+
+}
+
 #pragma mark - Code TableView
+- (UIView*)get_tableHeader
+{
+    return [UIView new];
+}
+-(void) resize_tableHeader
+{
+    //利用systemLayoutSizeFittingSize:计算出真实高度
+    CGFloat height = [self.editorTable.tableHeaderView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
+    CGRect headerFrame = self.editorTable.tableHeaderView.frame;
+    headerFrame.size.height = height;//20是留的上下边距
+    //修改tableHeaderView的frame
+    self.editorTable.tableHeaderView.frame = headerFrame;
+}
 - (void)initTableView {
     
     self.editorTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
     self.editorTable.translatesAutoresizingMaskIntoConstraints = NO;
+
     [self.tableContainer addSubview:self.editorTable];
     [self.tableContainer sendSubviewToBack:self.editorTable];
     
@@ -119,8 +140,8 @@
     self.editorTable.delegate = self;
     self.editorTable.dataSource = self;
     self.editorTable.tableFooterView = [UIView new];
-    self.editorTable.tableHeaderView = [UIView new];
-    
+//    self.editorTable.tableHeaderView = [UIView new];
+     self.editorTable.tableHeaderView = [self get_tableHeader];
 }
 
 - (void)registerPhoneCell {