根据标签栏控制器调整视图控制器的大小
在我的应用程序中,我开发了一个向导,在其中我为用户提供了一种逐一设置其详细信息的方法。完成所有步骤后,用户将被重定向到 TabBar 将出现的屏幕。
这里的问题是用户可以使用向导(没有 TabBar 控制器)和正常流程(有 TabBar 控制器)访问相同的视图控制器。在向导中,我使用大小为 320x480 的视图控制器,与正常流程中的大小相同。但是每当我使用 TabBar 加载任何视图控制器时,底部的 44 像素视图就会隐藏在 TabBar 后面。
我知道我可以通过检测 TabBar 是否存在来手动设置视图大小,但在这种情况下,视图控制器的数量更多,并且其尺寸已经设计为 320x480。
我已经尝试过苹果文档中给出的所有方法,但似乎没有一个对我有用。
以下是我尝试过的方法,以及一些 xib 设置。
[self setWantsFullScreenLayout:YES];
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.view setAutoresizesSubviews:YES];
[self.navigationController.view setNeedsLayout];
有没有办法根据 TabBar 是否存在来设置视图控制器的高度?
In my application, I have developed one wizard in which I am providing a way for the user to setup his details one-by-one. After finishing all steps, the user will be redirected to the screen where TabBar will come into the picture.
The problem here is that the user can access the same view controllers with the wizard (without TabBar controllers) and normal flow (which is with tabbar controller). In the wizard, I am using a view controller of size 320x480 and the same in normal flow. But whenever I load any view controller using TabBar the 44 pixel view from bottom side gets hidden behind TabBar.
I know the I can manually set the view size, by detecting whether TabBar is present or not, but here in this case number of view controllers are more and its already designed of size 320x480.
I had tried with all methods given in Apple's documentation but none of it seems to work for me.
Following are the methods I have tried, along with some xib settings.
[self setWantsFullScreenLayout:YES];
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.view setAutoresizesSubviews:YES];
[self.navigationController.view setNeedsLayout];
Is there any way to set the height of a view controller according to whether that TabBar is present or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就我而言,(状态栏/导航栏/隐藏选项卡栏)这有效
,但是如果您使用故事板,巴里的答案会更好,但我不能使用这个 VC。
尝试过 iOs7 和 iOs 8。
In my case, (Status bar/Nav bar/Hidden tabbar) this worked
However Barry's answer is better if you use Storyboard but I could not for this VC.
Tried for iOs7 and iOs 8.
如果您使用故事板,请选择每个选项卡 VC 并清除
View Controller
> 复选框。延伸边缘
>在底部栏下
。If you're using storyboards, select each tab VC and clear the box for
View Controller
>Extend Edges
>Under Bottom Bars
.我无法找到一个好的答案,所以我最终添加了一个 BOOL,hasTabBar。我根据创建视图的位置将其设置为 true 或 false,并使用它来计算我的布局。
I wasn't able to find a good answer for this, so I ended up adding a BOOL, hasTabBar. I set it true or false based on where I create my view, and use that to calculate my layouts.