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];
}

此方法在 iOS 8 中完美运行,但在 iOS 7 中崩溃,这种崩溃无处可去。

4

1 回答 1

1

我在代码中手动添加约束时遇到了同样的问题。在代码中,我正在执行以下操作: 据我所知,问题是当您禁用 translatesAutoresizingMaskIntoConstraints 解决方案:我的解决方案是将所有内容移动到 contentView。

    {
   [self.contentView addSubview:someView];
   [self.contentView addSubview:someOtherView];
   [self.contentView addConstraint:...];
}
于 2015-05-14T07:51:09.883 回答