正如你可以在截圖中看到這裏是灰色UIView
我作爲容器使用。在代碼中,我分配UINavigationController
並將其作爲子視圖添加到灰色容器視圖。 UINavigationController
有RootViewController
(您可以在左側看到截斷表視圖 - 它是我的UINavigationController的根視圖控制器)。
我的問題是如何將各方面的超級觀點界限。因爲現在我只能看到RootViewController
視圖的一部分。
在故事板中,我對灰色容器視圖設置了所有約束,對於RootViewController
視圖UINavigationController
進行了設置。如果我通常PushViewController
而不是添加作爲子視圖它顯示沒有中斷問題。
下面是一個代碼我在UIViewController
包含灰色容器視圖:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
KNCouponsViewController *couponsViewControllerByList = [KNInstantiateHelper instantiateViewControllerWithIdentifier:@"KNCouponsViewController"];
self.theNavigationController = [[UINavigationController alloc] initWithRootViewController:couponsViewControllerByList];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.theContainerView addSubview:self.theNavigationController.view];
}
下面是灰色容器視圖約束
這裏是根的視圖約束視圖控制器已切斷表格:
似乎是一個簡單的解決方案是設置UINavigationController
查看相同的寬和高爲灰色容器具有:
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect rect = self.theContainerView.frame;
rect.origin.x = 0;
rect.origin.y = 0;
[self.theNavigationController.view setFrame:rect];
[self.theContainerView addSubview:self.theNavigationController.view];
}
然後,它的工作原理是正確的。但是我認爲如果我們不修改一個框架,那麼它會起作用嗎?