インタースティシャル広告を表示するかどうかを Web サービスに照会するビュー コントローラーがあります。その場合、別のビュー コントローラーがインスタンス化され、presentViewController:animated:completion: を使用して提示されます。この回答とdocsによると、表示されたView Controllerを閉じるときに viewDidAppear: が呼び出されないと仮定します(それ自体が行います)。概念的には、とにかく、表示しているビュー コントローラーのビューがビュー階層から削除されることはないため、「再表示」する必要はありません。私は明らかに間違っています。それで、何が起こっているのですか?表示されている内容とドキュメントの内容が異なるのはなぜですか?
- (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];
}