2

Why do I add

static UIWindow *window_;
window_ = [[UIWindow alloc]init];
window_.frame = CGRectMake(0, 0, XMGScreenW, 20);
window_.windowLevel = UIWindowLevelAlert;
window_.hidden = NO;

to AppDelegate or Tarbarcontroller will crashes, but in the Controller will not crashes. I want to take the window covering on the status bar, set the click event。

Crash Message:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'

lyon Liu
  • 21
  • 4
  • see this one http://stackoverflow.com/questions/30884896/application-windows-are-expected-to-have-a-root-view-controller-at-the-end-of-a – Anbu.Karthik Apr 12 '16 at 09:08
  • may I ask why you want to initialize a new uiwindow object here? – John Tai Apr 13 '16 at 01:52
  • @JohnTai I want to take the window covering on the status bar, set the click event。 – lyon Liu Apr 13 '16 at 02:20
  • you mean like : ` - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { static UIWindow *window_; window_ = [[UIWindow alloc]init]; window_.frame = CGRectMake(0, 0, 320, 20); window_.windowLevel = UIWindowLevelStatusBar; window_.hidden = NO; UIViewController *VC = [[UIViewController alloc] init]; VC.view.backgroundColor = [UIColor redColor]; window_.rootViewController = VC; [window_ makeKeyAndVisible]; return YES; } ` – John Tai Apr 13 '16 at 02:35
  • @Anbu.Karthik Thank you, I solved my problem. – lyon Liu Apr 13 '16 at 04:05

0 Answers0