我正在进行一项高级项目,最近在闪屏后我的应用程序开始只加载黑屏。我没有使用storyboards。我一直在寻找解决这个问题的方法,但似乎不能将其他解决方案适应到我的项目中。 我的 [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
任何关于此的建议将不胜感激。
self.window
似乎是空的。尝试在你的application:didFinishLaunchingWithOptions:
中添加self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
。 - spassas