I have a UiViewController1 that loads an Admob interstitial, displays it when the user clicks a button, and loads another UiViewController2 when the user clicks out of the ad. However, I don't want the previous viewController to show, and the Admob interstitials are presented animated (I don't know of a way to stop this):
-(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];
}
I tried to load UIViewController2 before the ad is dismissed but, this happens:
Attempt to present <UIViewController1: 0x1355816a0>
on <UIViewController2: 0x135506490> whose view is not in the window hierarchy!
I guess you CANNOT modify AdMob
SDK's viewController presenting behaviour,
actually what you are doing is not really common.
I would suggest to do some workaround f.e adding your viewController2 as a child instead of presenting modally in interstitialdidDismiss
delegate