【发布时间】:2014-05-05 07:39:08
【问题描述】:
一个uiviewcontroller在stroyboard ib中添加了两个UIViews和一个tableview并与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];
}
我该如何解决这个问题?
【问题讨论】:
标签: ios objective-c ios7 uiview addsubview