我正在开发必须连续显示 iAd 的应用程序。谁能告诉我如何设置持续停留在屏幕上的 iAd。
提前致谢。
您必须将 iAd 带入应用程序 Delegate View 并设置将子视图置于最前面。在 Application Delegate 中添加这一行
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
[self createAdBannerView];
}
- (void)createAdBannerView
{
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil)
{
self.adBannerView = [[[classAdBannerView alloc] initWithFrame:CGRectZero] autorelease];
[_adBannerView setRequiredContentSizeIdentifiers:[NSSet setWithObjects: ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil]];
if (UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
[_adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifier480x32];
}
else
{
[_adBannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifier320x50];
}
if(DeviceFlag == 1)
{
[_adBannerView setFrame:CGRectOffset([_adBannerView frame], 0, -100)];
}
else
{
[_adBannerView setFrame:CGRectOffset([_adBannerView frame], 0, -70)];
}
//[_adBannerView setFrame:CGRectOffset([_adBannerView frame], 0, -[self getBannerHeight])];
[_adBannerView setDelegate:self];
[viewController.view addSubview:_adBannerView];
[self.window bringSubviewToFront:_adBannerView];
}
}