[英]Present view controller from app delegate
我正在嘗試使用以下代碼從應用程序委托呈現一個視圖控制器:
- (void)interstitialViewControllerRequestSucceeded:(UIViewController *)interstitialViewController
{
[self.window.rootViewController presentViewController:(UIViewController *)interstitialViewController animated:YES completion:NULL];
}
它將在初始視圖控制器上顯示插頁式廣告,但不顯示其他任何內容。 我希望它顯示在連接到導航控制器的每個控制器上。
如何修改此代碼以實現該目標?
你也可以試試:
[[[UIApplication sharedApplication] keyWindow] rootViewController]
我如何使用它:
#define ROOTVIEW [[[UIApplication sharedApplication] keyWindow] rootViewController]
[ROOTVIEW presentViewController:interstitialViewController animated:YES completion:^{}];
用於檢查響應的 Swift 3 版本:
UIApplication.shared.keyWindow?.rootViewController
檢查這個:
UIApplication.shared.windows.first?.rootViewController
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.