Xcode 7 测试版 ios 9 给出错误 'Application windows are expected to have a root view controller at the end of application launch'

Xcode 7 beta ios 9 giving error 'Application windows are expected to have a root view controller at the end of application launch'

这是我的代码。我正在使用 MTStatusBarOverlay too.This 代码在 运行 使用 xcode 时正常工作 6. 应用程序崩溃并给出错误

'Application windows are expected to have a root view controller at the end of application launch' .

我尝试过以多种不同的方式设置 rootViewController。我什至尝试覆盖 MTStatusBarOverlay

中的以下代码
     - (UIViewController *)rootViewController {
         ETAppDelegate *delegate = (ETAppDelegate *)[UIApplication sharedApplication].delegate;
         return delegate.window.rootViewController;
     }


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
         _didReceiveBackgroundNotification = NO;


         [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge];

         NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

         MTStatusBarOverlay *overlay = [MTStatusBarOverlay sharedInstance];
         overlay.animation = MTStatusBarOverlayAnimationNone;
         overlay.hidesActivity = YES;

         NSDictionary *bundleDictionary = [[NSBundle mainBundle] infoDictionary];
         NSString *currentVersion = [NSString stringWithFormat:@"%@ (%@)", [bundleDictionary objectForKey:@"CFBundleShortVersionString"], [bundleDictionary objectForKey:@"CFBundleVersion"]];

        [overlay postMessage:@"Test Application" stringByAppendingString:currentVersion]];

        [self.window makeKeyAndVisible];

        return YES;
    }



    - (UIWindow *)window{
       if (_window) return _window;

       _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
       [_window setRootViewController:self.rootViewController];

       return _window;
  }


  - (UIViewController *)rootViewController{
       if (_rootViewController) return _rootViewController;
       _rootViewController = [[ETNavigationController alloc] initWithNibName:nil bundle:nil];

       ETHomeMenuViewController *homeViewController = [[ETHomeMenuViewController alloc] initWithNibName:nil bundle:nil];
                  ((ETNavigationController*)_rootViewController).rootViewController = homeViewController;
      homeViewController = nil;
      return _rootViewController;
 }

因为MTStatusBarOverlayUIWindow的子类,而Xcode7现在指定为错误信息说:

Application windows are expected to have a root view controller at the end of application launch

这意味着在应用程序启动之前,您无法在没有根 viewcontroller 的情况下实例化 UIWindow。所以在应用程序启动之前不要调用 [MTStatusBarOverlay sharedInstance]