启动画面iOS后的黑屏

时间:2014-07-28 13:48:50

标签: ios objective-c xcode simulator

在高级项目上工作,我的应用程序最近在启动画面后开始只加载黑屏。我没有使用故事板。我一直在寻找这个问题的解决方案,但似乎无法适应我的项目的其他解决方案。我的[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

的.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

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

1 个答案:

答案 0 :(得分:5)

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

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

所以你的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;
}