Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 间隙性don';我没有出现。_Ios_Objective C_Interstitial - Fatal编程技术网

Ios 间隙性don';我没有出现。

Ios 间隙性don';我没有出现。,ios,objective-c,interstitial,Ios,Objective C,Interstitial,我使用此代码添加间隙: - (void)applicationDidBecomeActive:(UIApplication *)application { GADRequest *request = [GADRequest request]; request.testDevices = [NSArray arrayWithObjects: GAD_SIMULATOR_ID,

我使用此代码添加间隙:

    - (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]不能显示间隙。它还没有准备好。
2015-02-09 18:57:13.801 iStorbe[5951:1824030]没有为广告提供UIViewController。无法继续。


有什么想法吗?为什么?在其他应用程序中它可以工作。

在我的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];
}

你的根视图控件是什么?它是
UINavigationController
,还是
uitabarcontroller
,还是
UIViewController
?能否在
[gadiner presentFromRootViewController:self.window.rootViewController]前面添加一个
NSLog(%“%@”,self.window.rootViewController)
并查看值是什么?可能是
nil
?因为我正在查看。似乎他们将ad init代码放在了
viewDidLoad
中。当调用此
-(void)interstitutialdIDReceiveAD:(gadInterstitutial*)interstitutial
时,您的rootViewController可能还没有准备好。谢谢@YuchenZhong,我添加了viewDidLoad,现在一切正常。太好了,如果你已经弄明白了这一点,你可以写下你自己的答案,以便将来对其他人有所帮助..我尝试过这个方法,但由于某种原因interstitialDidReceiveAd从未执行过。如果我等待足够的时间,我可以手动显示广告,但是其他所有配置都正确,只是委托没有执行。