如何将AdWhirl-banner固定在TabBar上方?
我的应用程序由一个 TabBar 和几个 TableView 组成。我希望将 AdWhirl 横幅固定在 TabBar 上方(仅在第一个 TableView 中),但到目前为止我还没有成功。
到目前为止,我已经在我的 TableViewController 中实现了以下代码:
AdWhirlView *adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.tableView addSubview:adWhirlView];
adWhirlView.center = CGPointMake(160, 342);
它确实显示了我想要看到的广告,只是它被部分标题(来自 TableView)部分覆盖,并且当滚动广告时会滚动。
如何实现广告既位于顶部(就俯视图而言)又位于固定位置(TabBar 上方)?
非常感谢任何帮助!
My app consists of a TabBar and several TableViews. I want to have the AdWhirl-banner fixed just above the TabBar (only in the first TableView), but thus far I have not been succeeding.
Until now, I have implemented the following code into my TableViewController:
AdWhirlView *adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.tableView addSubview:adWhirlView];
adWhirlView.center = CGPointMake(160, 342);
And it indeed shows the Ad i want to see, only it is partly covered by a section header (from the TableView), and when scrolling the Ad scrolls along.
How can I achieve that the Ad is both on top (in terms of top view) and at a fixed spot (above the TabBar)?
Any help is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将其添加到 tabBar 层。
试试这个:
您可能需要重新定位它,因为它不在选项卡栏下方。
我还在表格中添加了页脚,这样它们就可以一直向上滚动,而不会受到广告的干扰。
You need to add it to the tabBar layer.
Try this:
You may need to reposition it do it's not underneath the tabbar.
I also add a footer to the tables so they can be scrolled all the way up without the ad getting in the way.
您可能需要创建自己的 UIViewController 子类,以编程方式或在 nib 文件中将 AdWhirlView 和 UITableView 的实例添加到其视图中。
Anthoer,更黑客的方法是将 AdWhirlView 添加为现有表中的标题视图,但我会选择第一种方法。它将让您更好地控制您想要的外观和行为。
You will likely need to create your own subclass of UIViewController, adding instances of both the AdWhirlView and UITableView to its view, either programatically, or in the nib file.
Anthoer, hackier way to do this would be to add the AdWhirlView as a header view in the existing table, but I'd opt for the first way. It will give you more control over how you want it to look and behave.
我认为这里的另一种选择是拥有一个容器 UIView,其中包含 UITTabBar 和 UITableView。如果您位于正确的选项卡上,则只需请求广告即可。如果请求成功,只需将选项卡式视图缩小到足以为顶部的广告腾出空间并将其插入到容器 UIView 中即可。
I'd think another alternative here would be to have a container UIView that contains both a UITTabBar which contains a UITableView. If you're on the right tab, you could just request an ad. If the request is successful, just shrink the tabbed view enough to make room for the ad at the top and insert it into the container UIView.