2015-02-09 48 views
1

我用這個代碼加間質性:插頁式廣告不會出現。

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
    GADRequest *request = [GADRequest request]; 

    request.testDevices = [NSArray arrayWithObjects: 
          GAD_SIMULATOR_ID, 
          nil]; 



    gadinter = [[GADInterstitial alloc] init]; 
    gadinter.delegate = self; 
    gadinter.adUnitID = @"ca-app-pub-8360827428091030/4165686904"; 

    [gadinter loadRequest:request]; 
} 

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial { 

    [gadinter presentFromRootViewController:self.window.rootViewController]; 
} 

,我得到這個:

2015-02-09 18:57:12.636 iStrobe[5951:1824030] <Google> Cannot present interstitial. It is not ready. 2015-02-09 18:57:13.801 iStrobe[5951:1824030] <Google> No UIViewController supplied to the ad. Cannot continue.

任何IDEEA爲什麼?在其他應用程序的作品。

+0

你是什麼rootViewControlelr?它是'UINavigationController'還是'UITabBarController'或'UIViewController'? – 2015-02-09 18:23:07

+0

UIVIewController – 2015-02-09 18:23:53

+0

您可以在'[gadinter presentFromRootViewController:self.window.rootViewController]'前面添加一個'NSLog(%「%@」,self.window.rootViewController)'並查看該值是什麼?它可能是'無'? – 2015-02-09 18:33:55

回答

0

在我的viewController我加入就是說:

- (void)viewDidLoad { 


    GADRequest *request = [GADRequest request]; 

    request.testDevices = [NSArray arrayWithObjects: 
          GAD_SIMULATOR_ID, 
          nil]; 



    gadinter = [[GADInterstitial alloc] init]; 
    gadinter.delegate = self; 
    gadinter.adUnitID = @"ca-app-pub-8360827428091030/4165686904"; 

    [gadinter loadRequest:request]; 

} 

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial { 
    [gadinter presentFromRootViewController:self]; 
} 
+0

我試過這個,由於某種原因interstitialDidReceiveAd從不執行。我可以手動顯示廣告,如果我等待了足夠的時間,但其他所有內容都已正確配置,那只是委託沒有執行。 – Jackson 2017-01-22 23:52:39