【发布时间】:2014-09-19 17:31:14
【问题描述】:
从事高级项目,最近我的应用在启动画面后开始仅加载黑屏。我没有使用故事板。我一直在寻找解决这个问题的方法,但似乎无法为我的项目调整其他解决方案。我的 [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]];
标签: ios objective-c xcode simulator