为什么我的标签在 ViewContainer 内 UITabbarController 的标签栏下 [英] Why my label is under tab bar from UITabbarController inside ViewContainer

查看:22
本文介绍了为什么我的标签在 ViewContainer 内 UITabbarController 的标签栏下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在 Xcode 中为 TabBar 应用程序创建了一个新的项目模板.

I just create a new project template for TabBar application in Xcode.

我安排了一个故事板,让 UITabbarController 像这样嵌入到另一个视图控制器中(以便为所有标签页提供红色标题)

I arrange a storyboard to let a UITabbarController embedded in another view controller like this (in order to provide red header for all tab pages)

请注意,在第一个标签页中,我在第一页上放置了两个标签.两者都位于屏幕的顶部和底部.

Notice that in first tab page, I put two labels on the first page. Both are locating at the top and bottom of the screen.

这是第一个选项卡视图控制器的设置.

and here is a setting of first tab view controller.

这是我在设备和模拟器上得到的结果.

and this is the result i have got on both device and simulator.

为什么以及如何显示我的第二个标签的一半?我尝试取消选中所有选项和设置

Why and how can my second label half shown? i try to uncheck all options and setting

self.automaticallyAdjustsScrollViewInsets = NO;
self.edgesForExtendedLayout = UIRectEdgeNone;

但没有一个工作.

我该如何解决这个问题?

How can I solve this?

谢谢.

更新

我已经知道这背后的罪魁祸首是什么.它是 ipad 横向模式的标签栏高度,通常高度为 49,但根据苹果 这里

I already know what is the culprit behind this. It is the tabbar's height for ipad landscape mode normally the height is 49 but according to apple here

他们说 ipad 的高度为 56.

They said the height will be 56 for ipad.

但在界面构建器中,它始终为 49,并且即使我使用自动布局,每个选项卡中我的视图控制器的根视图也是使用这 49 个选项卡栏高度计算的.

But in interface builder, it is always 49 and and the rootviews of my viewcontroller in each tab are calculate using this 49 height of tabbar even though i use an autolayout.

所以我有办法通过创建另一个视图来克服这个问题,让它的高度比 rootview 小 7 个像素.

So I have a way to overcome this by create another view and let it has smaller height by 7 pixel from rootview.

但是为什么界面构建器显示 49 像素的标签栏而不是 56 像素?

But WHY interface builder display 49 pixel of tabbar instead of 56?

推荐答案

我不太清楚你真正要问的是什么,但如果你只是想在你的视图控制器顶部有一个红色的标题,你可以嵌入它们在 UINavigationController 内部.即使您仍然想要一个 UITabBarController,也可以将每个子视图嵌入到 UINavigationController 中,然后您就可以控制标题的外观.

It is not quite clear to me what you are really asking, but if you simply want a red header at the top of your view controllers, you can embed them inside of an UINavigationController. Even if you still want a UITabBarController, embed every child view inside of a UINavigationController and then you can control the look of your header.

(注意:我只是将其添加为评论,但我没有声誉.)

(Note: I would just add this as a comment but I don't have the reputation.)

这篇关于为什么我的标签在 ViewContainer 内 UITabbarController 的标签栏下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆