I have a view controller which queries a web service as to whether an interstitial ad should be shown. If so, another view controller is instantiated and presented using presentViewController:animated:completion:. According to this answer and the docs, I would assume viewDidAppear: would not be called when dismissing the presented view controller (which it does itself). Conceptually, to me anyway, the presenting view controller's view is never removed from the view hierarchy and therefore never needs to "reappear". I'm obviously wrong. So what is going on? Why is what I'm seeing differing from what the docs say?
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[AdService sharedAdService] adForSlotName:@"Main Interstitial" completionBlock:^(Ad *adForSlotName) {
if(adForSlotName)
{
InterstitialAdViewController_iPhone *interstitialAdViewController = [[InterstitialAdViewController_iPhone alloc] init];
interstitialAdViewController.ad = adForSlotName;
dispatch_queue_t mainQueue = dispatch_get_main_queue();
dispatch_async(mainQueue, ^{
[self presentViewController:interstitialAdViewController animated:YES completion:^{}];
});
[interstitialAdViewController release];
}
}];
}
- (void)viewWillDisappear:(BOOL)animated
{
[[AdService sharedAdService] clearAdForSlotName:@"Main Interstitial"];
[super viewWillDisappear:animated];
}