调整 UITabBarController 中视图的大小,使其不出现在选项卡栏后面
我设置了一个应用程序,其中窗口包含一个选项卡栏控制器,其中一个选项卡加载一个名为“ShowCaseView.xib”的 NIB;该文件由自定义 ShowcaseViewController
类拥有。
在 ShowcaseViewcontroller
类中,我添加了一个 UIScrollView
对象,如下所示:
imageScrollView = [[UIScrollView alloc] initWithFrame:[[self view] bounds]];
[[self view] addSubview:imageScrollView];
我遇到的问题是这个 UIScrollView
对象扩展了 < em>在我的标签栏控制器下面。
所以我不得不手动减少它的插入:
#define TAB_BAR_HEIGHT 48
.
.
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(0, 0, TAB_BAR_HEIGHT, 0);
[imageScrollView setScrollIndicatorInsets:edgeInsets];
那么,
- 通常需要从视图中手动扣除标签栏高度(无论是通过减少子视图的大小还是检查器中的视图NIB)?
- 有没有一种方法可以告诉从选项卡栏加载的 NIB 视图自动调整自身大小,而不是位于选项卡栏后面?
I have an application set up where the window contains a tab bar controller and one of the tabs loads a NIB called 'ShowCaseView.xib'; this file is owned by a custom ShowcaseViewController
class.
In the ShowcaseViewcontroller
class I have added a UIScrollView
object, like so:
imageScrollView = [[UIScrollView alloc] initWithFrame:[[self view] bounds]];
[[self view] addSubview:imageScrollView];
The issue I am having is that this UIScrollView
object extends beneath my tab bar controller.
So I have had to reduce its insets manually:
#define TAB_BAR_HEIGHT 48
.
.
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(0, 0, TAB_BAR_HEIGHT, 0);
[imageScrollView setScrollIndicatorInsets:edgeInsets];
So,
- Is it common to have to manually deduct the tab bar height from a view (whether this be by reducing the size of subviews or the View NIB in inspector)?
- Is there a way that I can tell a NIB's view loaded from a tab bar to resize itself automatically to NOT sit behind the tab bar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 NIB 文件中,视图的“大小和位置”是否设置为“框架”?我应该是布局。
In the NIB file is the "Size & Position" for the view set to "Frame"? I should be Layout.