- (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.
这种方法在iOS 8中完美运行,但在iOS 7中崩溃,这种崩溃来自任何地方。
1 个解决方案
#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.
我在代码中手动添加约束时遇到了同样的问题。在代码中,我正在做以下事情:从我所知,问题是当你禁用translatesAutoresizingMaskIntoConstraints解决方案时:我的解决方案是将所有内容移动到contentView。
{
[self.contentView addSubview:someView];
[self.contentView addSubview:someOtherView];
[self.contentView addConstraint:...];
}
#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.
我在代码中手动添加约束时遇到了同样的问题。在代码中,我正在做以下事情:从我所知,问题是当你禁用translatesAutoresizingMaskIntoConstraints解决方案时:我的解决方案是将所有内容移动到contentView。
{
[self.contentView addSubview:someView];
[self.contentView addSubview:someOtherView];
[self.contentView addConstraint:...];
}