Advertisement
undeadhip

Untitled

Sep 2nd, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)viewDidLoad {
  2.     [super viewDidLoad];
  3.  
  4.     PostWithHeaderView *postView = [[PostWithHeaderView alloc] initWithFrame:CGRectMake(0, 0, 320, CGFLOAT_MAX)];
  5.     postView.post = self.post;
  6.     self.tableView.tableHeaderView = postView;
  7. }
  8.  
  9. - (void)viewDidLayoutSubviews {
  10.     [super viewDidLayoutSubviews];
  11.    
  12.     UIView *postView = self.tableView.tableHeaderView;
  13.     [postView setNeedsLayout];
  14.     [postView layoutIfNeeded];
  15.     CGFloat height = [postView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  16.     NSLog(@"HEIGHT %f",height);
  17.    
  18.     //update the header's frame and set it again
  19.     CGRect headerFrame = postView.frame;
  20.     headerFrame.size.height = height;
  21.     postView.frame = headerFrame;
  22.    
  23.     self.tableView.tableHeaderView = postView;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement