显示插页时加载和显示视图

时间:2014-08-25 19:46:42

标签: ios objective-c uiviewcontroller admob interstitial

我有一个UiViewController1,用于加载Admob插页式广告,在用户点击按钮时显示,并在用户点击广告时加载另一个UiViewController2。但是,我不希望以前的viewController显示,并且Admob插页式广告是动画的(我不知道如何阻止它):

-(void)viewDidLoad {
    [super viewDidLoad];

    interstitial = [[GADInterstitial alloc] init];
    interstitial.adUnitID = @"ca-app-pub-7102519969826764/7522738211";
    interstitial.delegate = self;

    GADRequest *request = [GADRequest request];
    request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,@"TheIDAppearingInLogs",nil];
    [interstitial loadRequest:request];   
}

-(void)onButtonPush {
    if (interstitial.isReady) {
        [interstitial presentFromRootViewController:self];
    } else {
        UIViewController2 *viewController = [[UIViewController2 alloc] init];
        [self presentViewController:viewController animated:NO completion:nil];
    }
}

-(void)interstitialDidDismissScreen:(GADInterstitial *)ad {
    UIViewController2 *viewController = [[UIViewController2 alloc] init];
    [self presentViewController:viewController animated:NO completion:nil];
}

我尝试在广告被取消之前加载UIViewController2但是,这种情况发生了:

Attempt to present <UIViewController1: 0x1355816a0> 
on <UIViewController2: 0x135506490> whose view is not in the window hierarchy!

1 个答案:

答案 0 :(得分:0)

我猜你不能修改AdMob SDK的viewController呈现行为, 实际上你所做的并不常见。

我建议做一些解决方法f.e将viewController2作为子项添加,而不是在interstitialdidDismiss委托中以模态方式呈现