我想构建一个使用2个容器视图嵌入UINavigationControllers的iPad的自定义拆分视图控制器...我设法做所有,但我有设置约束的问题,以便一切都很好地调整。使用容器视图构建自定义拆分视图
这是我到目前为止有:
我不会要能够在某种程度上调整主视图(左容器),其详细视图(右容器)调整本身也消耗空间大师在自我调整的同时向左看。所以我想结束这样的:
其他尝试中我尝试添加这些约束:
主容器:顶父母,离开父母,底部的TabBar,高度,占位符宽度 当我从代码调整主容器的大小时,细节控制器始终停留在其原始位置。当我从代码调整主容器的大小时,细节控制器始终停留在其原始位置。
我试过100个场景,没有任何工作。
我做什么根本性的错误自动布局,但只是无法弄清楚什么..
这是调整大小代码:
-(void)ShowMaster:(BOOL)bShow animated:(BOOL)bAnimated
{
CGRect frame = masterViewContainer.frame;
if(bShow){
frame.size.width = 280;
}
else{
frame.size.width = 50;
}
masterViewContainer.frame = frame;
}
任何形式的帮助将非常感激。
编辑: OK,我取得了一些进步,取代了我调整大小的代码与这一个:
-(void)ShowMaster:(BOOL)bShow animated:(BOOL)bAnimated
{
[UIView beginAnimations:@"" context:nil];
if(bShow){
[masterViewContainer addConstraint:[NSLayoutConstraint constraintWithItem:masterViewContainer
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:masterViewContainer
attribute:NSLayoutAttributeWidth
multiplier:0.5
constant:280]];
}
else{
[masterViewContainer addConstraint:[NSLayoutConstraint constraintWithItem:masterViewContainer
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:masterViewContainer
attribute:NSLayoutAttributeWidth
multiplier:0.5
constant:50]];
}
[UIView commitAnimations];
}
现在细节调整大小,但是当我尝试展开主,什么也没有发生......
不,它不起作用,但我想它谢谢,无论如何... – AntonijoDev