Changing the height of a tableHeaderView hides the cells

前端 未结 2 843
花落未央
花落未央 2021-02-13 11:17

In my UITableView, I have a tableHeaderView that should resize itself according to the content. The resizing works fine, however, the tableHeaderView obscures the first couple o

相关标签:
2条回答
  • 2021-02-13 12:05

    Try setting the tableHeaderView property of the UITableView after you resized your content.

    [self.tableView setTableHeaderView:self.myResizedTableHeaderView];
    

    Solved the problem for me. Hope it helps.

    0 讨论(0)
  • 2021-02-13 12:07

    I don't know how you created you UITableView, but I tried to create one with a tableHeaderView like you and it's resizing.

    I created a class inheriting from UITableViewController

    @interface MyTableViewController : UITableViewController {
    
    }
    
    @end
    

    and for the implementation, in the viewDidLoad, I added:

    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    [header setBackgroundColor:[UIColor redColor]];
    self.tableView.tableHeaderView = header;
    

    enter image description here

    0 讨论(0)
提交回复
热议问题