【发布时间】:2018-09-08 16:34:12
【问题描述】:
我有一个包含 UITableview 的容器视图。通过调试构建,一切看起来都不错-
但是随着发布构建,childviewcontroller 出现 inset-
这是实例化视图的代码-
self.dailyWeatherTableViewController=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"DailyForecastViewController"];
self.dailyWeatherTableViewController.view.frame =self.view.frame;
UIEdgeInsets newSafeArea;
newSafeArea.top=self.headerView.frame.size.height;
if (@available(iOS 11.0, *)) {
self.dailyWeatherTableViewController.additionalSafeAreaInsets=newSafeArea;
} else {
// Fallback on earlier versions
}
[self addChildViewController:self.dailyWeatherTableViewController];
[self.forecastContainerView addSubview:self.dailyWeatherTableViewController.view];
[self.dailyWeatherTableViewController didMoveToParentViewController:self];
视图层次结构调试器显示 UITableviewCellContentView 的封装布局宽度设置为 261。一些谷歌搜索似乎表明这与视图的自动调整掩码有关,但更改此设置或在 cellforindex 方法中设置视图的框架并不能解决此问题。
这是tableview约束的截图-
【问题讨论】:
-
哪些元素的尺寸不正确?为您的视图提供不同的背景颜色,以便您可以清楚地看到元素的框架。
-
我用视图层次调试器做了一些挖掘,看起来罪魁祸首可能是单元格的内容视图,但我不知道如何修复它。请参阅上面的问题编辑。
-
很难说...我假设您没有收到任何自动布局警告/错误?
encapsulated-layout width有可能(可能?)被 tableView 的宽度设置/强制... tableView 本身看起来如何(在调试视图层次结构中)? -
另外你说“这里是实例化视图的代码”但是在哪里呢?您确实意识到
viewDidLoad绝对是错误的地方这样做????除非您也提供自动调整大小或自动布局,但您似乎都没有这样做。 -
@DonMag uitableviewcontroller 和单元格在 375 处似乎已满,但 contentview 为 261。
标签: ios uitableview autolayout storyboard uicontainerview