尽管这个答案可能是正确的,但我仍然发现自己必须向上移动包含树以找到正确的父视图控制器并获得您所描述的“真实topLayoutGuide”。这样我可以手动实现automaticallyAdjustsScrollViewInsets。
这就是我的做法:
在我的表视图控制器(UIViewController实际上是其子类)中,我有以下内容:
- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    _tableView.frame = self.view.bounds;
    const UIEdgeInsets insets = (self.automaticallyAdjustsScrollViewInsets) ? UIEdgeInsetsMake(self.ms_navigationBarTopLayoutGuide.length,
                                                                                               0.0,
                                                                                               self.ms_navigationBarBottomLayoutGuide.length,
                                                                                               0.0) : UIEdgeInsetsZero;
    _tableView.contentInset = _tableView.scrollIndicatorInsets = insets;
}
注意中的category方法UIViewController,这是我实现它们的方式:
@implementation UIViewController (MSLayoutSupport)
- (id<UILayoutSupport>)ms_navigationBarTopLayoutGuide {
    if (self.parentViewController &&
        ![self.parentViewController isKindOfClass:UINavigationController.class]) {
        return self.parentViewController.ms_navigationBarTopLayoutGuide;
    } else {
        return self.topLayoutGuide;
    }
}
- (id<UILayoutSupport>)ms_navigationBarBottomLayoutGuide {
    if (self.parentViewController &&
        ![self.parentViewController isKindOfClass:UINavigationController.class]) {
        return self.parentViewController.ms_navigationBarBottomLayoutGuide;
    } else {
        return self.bottomLayoutGuide;
    }
}
@end
希望这可以帮助 :)
     
              
topLayoutGuide为嵌套ViewController包含实现足够的实现。提出一个问题,即如果实现自定义容器,人们将如何处理它……