0
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    if (employeeListModel.count > 0) {
        if ([employeeListModel count]*90 < self.view.bounds.size.height-64) {
            CGRect frame = self.empListTableView.frame;
            frame.size.height = [employeeListModel count]*90;
            self.empListTableView.frame = frame;
            //self.empListTableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, [employeeListModel count]*90);
        } else {
            self.empListTableView.frame = self.view.bounds;
        }
    }
    [self.empListTableView layoutIfNeeded];
}

This method works perfectly in iOS 8 but crashes in iOS 7 , this crashes come from nowhere.

Bhuvan Bhatt
  • 3,276
  • 2
  • 18
  • 23
  • what do you have on the console? where exactly it crashes? – Julian May 13 '15 at 06:57
  • I get -- Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after sending -viewDidLayoutSubviews to the view controller. EmployeeListVC's implementation needs to send -layoutSubviews to the view to invoke auto layout.' – Bhuvan Bhatt May 13 '15 at 07:03
  • I advise you to change [self.empListTableView layoutIfNeeded] to be [self.view layoutIfNeeded]. – ondermerol May 13 '15 at 09:01
  • I changed that too but in that case tableview height is still not changing. It remains same as screen height. – Bhuvan Bhatt May 13 '15 at 11:14

1 Answers1

1

I got the same problem while manually adding constraints in code. In code, I was doing the following: From what I can tell, the issue is that when you disable translatesAutoresizingMaskIntoConstraints Solution: My solution was to move everything to the contentView.

    {
   [self.contentView addSubview:someView];
   [self.contentView addSubview:someOtherView];
   [self.contentView addConstraint:...];
}
Deepak Thakur
  • 129
  • 2
  • 12