我有一个UIView
调用updatesView这是主视图的子视图。基于某些条件,视图高度会发生变化。但视图高度只更改一次。下一次当我改变它时,它会显示之前的高度。UIView高度不变
- (void)viewWillAppear:(BOOL)animated
{
if (userLoggedIn)
[self resetSubviews];
else
[self setupSubviews];
}
-(void)resetSubviews
{
CGRect updateFrame = self.updatesView.frame;
updateFrame.size.height =self.notificationContainerView.frame.size.height - self.headerView.frame.size.height;
self.updatesView.frame = updateFrame;
}
- (void)setupSubviews
{
CGRect updateFrame = self.updatesView.frame;
updateFrame.size.height = self.notificationContainerView.frame.size.height - self.tabView.frame.size.height - self.buttonsView.frame.size.height - kHomeTabbarHeight - 5;
self.updatesView.frame = updateFrame;
}
假设最初运行应用程序userIsLoggedIn时,它执行第一个条件。现在,如果我注销(在另一个UIViewController
)并返回,则会执行else条件,但显示高度时不会更改。
同样,如果执行else条件,最初在运行应用程序时,视图高度始终保持与在该条件下设置的相同。
我没有使用自动布局。但我已经使用了自动调整。请有人能告诉我我做错了什么吗?
如何在故事板中使用约束时不使用自动布局? o_O 仅在自动布局中支持约束! – arturdev
我的意思是自动调整。 – JMS
您无法直接更改高度宽度。你必须改变更新高度的视野 –