2011-10-10 82 views
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 Simulator

回答

0

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

我建议你看看苹果的演示iAd代码,特别是AdBannerNavigation.app。

另一个选项可能是使用mobClix框架,您可以将iAd横幅添加到导航控制器。

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

p.s.您是否在添加bannerview之前尝试添加和调整导航控制器大小?

相关问题