获取 UITabBar 下方的输入
我有一个横幅,需要在选项卡栏控制器内的选项卡栏下方显示。让其显示并不是困难的部分,我已经解决了这个问题,但是不知何故,我使用的方法似乎将其置于接收输入的正常区域之外。
基本上,我使用这个横幅作为广告,但我不希望它覆盖标签栏。
这是我用来在选项卡栏下方创建横幅的代码:
const float footerHeight = 34.5;
const float statusBarHeight = 20.f;
const float viewHeight = 480 - statusBarHeight - bannerHeight - footerHeight;
const float viewY = 0 + statusBarHeight + bannerHeight;
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, viewHeight, 320, footerHeight)];
[footerView setContentMode:UIViewContentModeScaleToFill];
[footerView addSubview:footerButton];
[self.tabBarController.view addSubview:footerView];
[footerView release];
self.tabBarController.view.frame = CGRectMake(0, viewY, 320, viewHeight);
仅供参考,在某些变量中,视图顶部上方还有一个标题。 footerButton
是我在 IB 中创建并连接的 UIButton。
I've got a banner that I need to display below a tab bar within a tab bar controller. Getting it to display isn't the hard part, I have that solved already, however it seems somehow that the method I am using seems to be putting it outside the normal area for input to be received.
Basically, I am using this banner as an advertisement, but I do not wish for it to cover the tab bar.
Here's the code I am using to create the banner below the tab bar:
const float footerHeight = 34.5;
const float statusBarHeight = 20.f;
const float viewHeight = 480 - statusBarHeight - bannerHeight - footerHeight;
const float viewY = 0 + statusBarHeight + bannerHeight;
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, viewHeight, 320, footerHeight)];
[footerView setContentMode:UIViewContentModeScaleToFill];
[footerView addSubview:footerButton];
[self.tabBarController.view addSubview:footerView];
[footerView release];
self.tabBarController.view.frame = CGRectMake(0, viewY, 320, viewHeight);
just for reference in some of the variables there is also a header above the top of the view as well. footerButton
is a UIButton that I have created and hooked up in IB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终设法解决了这个问题,方法是在根
UIWindow
对象上放置一个UITapGestureRecognizer
,然后手动执行矩形检查以查看它是否在正常的较小范围内tabBarController 并将输入转发到我的页脚栏,否则I ultimately managed to work around this issue by putting a
UITapGestureRecognizer
on the rootUIWindow
object and then manually doing the rect cheecks to see if it is within the normal, smaller bounds of the tabBarController and forwarded the input to my footer bar otherwise