启动画面iOS后的黑屏

use*_*919 2 xcode simulator objective-c ios

在高级项目上工作,我的应用程序最近在启动画面后开始只加载黑屏.我没有使用故事板.我一直在寻找这个问题的解决方案,但似乎无法适应我的项目的其他解决方案.我的[github](https://github.com/cleif/Hastings/tree/Fixed)在这里有最新版本.下面是我的AppDelegate.h和.m文件中的代码.

.H

#import <UIKit/UIKit.h>
#import "IIViewDeckController.h"
#import "MenuViewController.h"
#import "HomeViewController.h"
#import "AboutViewController.h"
#import "AthleticsViewController.h"
#import "BroncoBoardViewController.h"
#import "ContactsTableViewController.h"
#import "MapViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (retain, nonatomic) UIViewController *menuViewController;
@property (retain, nonatomic) UIViewController *rootViewController;

@end
Run Code Online (Sandbox Code Playgroud)

.M

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize menuViewController = _menuViewController;

- (IIViewDeckController*) initializeMainViewControllers {

UIViewController *menuViewController      = [[MenuViewController alloc] init];
UIViewController *rootViewController      = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];

IIViewDeckController* deckController      = [[IIViewDeckController alloc] initWithCenterViewController:[[UINavigationController alloc] initWithRootViewController:rootViewController]
                                                                                    leftViewController:menuViewController];

return deckController;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

IIViewDeckController* deckController    = [self initializeMainViewControllers];

self.menuViewController                 = deckController.leftController;
self.rootViewController                 = deckController.centerController;

self.window.rootViewController          = deckController;
[self.window makeKeyAndVisible];

return YES;
}

@end
Run Code Online (Sandbox Code Playgroud)

对此有任何建议将不胜感激.

Moh*_*hit 5

我得到你的代码并添加到以下行 - (BOOL)应用程序:(UIApplication*)应用程序didFinishLaunchingWithOptions:(NSDictionary*)launchOptions,现在工作正常

self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; 
Run Code Online (Sandbox Code Playgroud)

所以你的didFinishLaunchingWithOptions方法必须是这样的

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

IIViewDeckController* deckController    = [self initializeMainViewControllers];

self.menuViewController                 = deckController.leftController;
self.rootViewController                 = deckController.centerController;

self.window.rootViewController          = deckController;
[self.window makeKeyAndVisible];

return YES;
}
Run Code Online (Sandbox Code Playgroud)