2011-10-10 67 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之前嘗試添加和調整導航控制器大小?

相關問題