0

我希望在窗口底部的应用程序中加载 iAd 横幅,并将应用程序的其余部分、UINavigationController 和视图放在窗口的顶部。我已经尝试并尝试使用我的数学和逻辑技能,但似乎无法让它们正确显示。

iAd 横幅显示在正确的位置,但 NavigationController 没有。

//AppDelegate.h
AdViewController *adController;
UINavigationController *navController;
UIViewController *containerView;

//.m file didFinishLaunching...
//views and controllers already initialized
containerView.view.frame = [[UIScreen mainScreen]bounds];
[containerView.view addSubview self.adController.view];
[containerView.view addSubview self.navController.view];

//hard coded frame for an ADBannerView (loaded in .xib)
CGRect bannerFrame = self.adController.view.frame;

//sets the start point vertically by subtracting the 
//banner height from the total height of the screen
//in this case, 480 - 50
bannerFrame.origin.y = [[UIScreen mainScreen]bounds].size.height - bannerFrame.size.height;

self.adController.view.frame = bannerFrame;

//returns a rectangle that takes the 20 px status bar into account
//this rectangle's y origin is at 20
CGRect appFrame = [[UIScreen mainScreen]applicationFrame];

//This CGRect is assuming the applicationFrame
CGRect navFrame = appFrame;

//subtract the banner height from the navFrame height
//takes 50 px off of the height
navFrame.size.height = navFrame.size.height - bannerFrame.size.height;

self.navController.view.frame = navFrame;

iOS 模拟器

4

1 回答 1

0

iAd 横幅需要一个视图控制器。此外,Apple 说视图控制器应该控制整个屏幕的视图——直到我们可以在 ios5 中编写自己的容器视图。

我建议您查看 Apple 的演示 iAd 代码,尤其是 AdBannerNavigation.app。

另一种选择可能是使用 mobClix 框架,您可以使用它向导航控制器添加 iAd 横幅。

我假设您正在计划什么时候没有广告可显示?因为有时填充率可能很低。

ps您是否尝试在添加bannerview之前添加导航控制器并调整其大小?

于 2011-10-10T15:56:19.047 回答