2015-01-04 131 views
0

自从我从头开始创建项目以来,这已经有一段时间了。当时在XCode 4/5中,开发人员可以在storyboard或Xib之间进行选择以启动项目。在Xcode 6中,尽管每个模板都被迫作为StoryBoard开始使用。Xib无法正常加载

我已经删除了故事板。然后我在支持文件中打开info.plist,并将Main storyboard file base name : Main设置为Main storyboard file base name: <blank>

然后我用Xib(同名)创建了一个基本的testViewController。

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (nonatomic, retain) IBOutlet UIWindow *window; 
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 

@end 



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    testViewController *firstViewController = [[testViewController alloc] initWithNibName:nil bundle:nil]; 
    self.navigationController.viewControllers = [NSArray arrayWithObject:firstViewController]; 
    self.window.rootViewController = self.navigationController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

而这仍然显示我一个黑色的视图控制器。我检查了xib文件,将文件所有者设置为视图控制器,并且还设置了视图代理。 我错过了什么?

回答

0

变化这两个东西:

@property (nonatomic, retain) IBOutlet UIWindow *window; 

testViewController *firstViewController = [[testViewController alloc] initWithNibName:nil bundle:nil]; 

此,添加以下代码,与真实名称或XIB文件:

@property (nonatomic, retain) UIWindow *window; // Are you using ARC? 

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

// I think your xib files is testViewcontroller.xib, if not change it. 
testViewController *firstViewController = [[testViewController alloc] initWithNibName:testViewController.xib bundle:nil]; 
// change this also 
self.navigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController]; 

self.window.rootViewController = self.navigationController; 
[self.window makeKeyAndVisible]; 
return YES;