【发布时间】:2015-11-17 15:43:43
【问题描述】:
这是我的代码。我也在使用 MTStatusBarOverlay。此代码在使用 xcode 6 运行时正常工作。应用程序崩溃并给出错误
'应用程序窗口应该有一个根视图控制器 应用程序启动结束。
我尝试以多种不同的方式设置 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;
}
【问题讨论】: