2014-03-26 59 views
1

uiviewcontroller具有两个UIViews和一个tableview在stroyboard IB并用IBoutlet添加子视图以查看变化的其他子视图帧

当在顶部的UIView用户点击轻扫,我调用下面的方法来改变所有的帧连接子视图IBoutlet元素。这样可行。

-(void)hideTopViews 
{ 
    [UIView animateWithDuration:0.25 animations:^{ 
     [_overallHealth setHidden:YES]; 
     _overallHealth.frame = CGRectMake(0, 0,self.view.frame.size.width,0); 
     [_healthBar setHidden:YES]; 
     _sortView.frame = CGRectMake(0, 45,self.view.frame.size.width,_sortView.frame.size.height); 
     _portfoList.frame = CGRectMake(0, _sortView.frame.origin.x+_sortView.bounds.size.height+50,self.view.frame.size.width,self.view.frame.size.height); 
     _sortButton.frame = CGRectMake(90, 45,_sortButton.frame.size.width,_sortButton.frame.size.height); 
     [self.view bringSubviewToFront:_sortButton]; 
     self.navigationItem.leftBarButtonItems=nil; 
    }]; 


} 

然而,当我添加一个子视图编程到self.view所有子视图回到原来的位置就像在故事板。

-(void)showPortfolioDetailsScreen 
{ 
    PortfolioDetails *portView=[[PortfolioDetails alloc] initWithFrame:CGRectMake(300,200,200,200)]; 
    portView.backgroundColor=[UIColor redColor]; 
    [self.view addSubview:portView]; 

} 

enter image description here

enter image description here

enter image description here

我该如何解决这个问题?

+2

为自动关闭布局? – tanzolone

回答

0

@tanzolone是在正确的轨道,如果你只使用肖像模式,并希望自己的故事板,停止改变你的子视图原始帧去你的故事板,并取消Use Autolayout

,所以你可以使用旧的支柱和 - 弹簧模型。

这里是自动版式的详细教程,虽然 http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2

+0

如何在不移除自动布局的情况下解决此问题?是否有可能? – yhpets

相关问题