我有一个示例xcode项目,我下载测试了这个。它有2个.xib文件(每个文件都有自己的视图控制器头和主电源)。我添加了一个故事板并将ViewControllers类设置为game和ViewController(.xibs的名称),并在摘要中将主故事板设置为故事板,但每当我运行应用程序时,它只运行.xibs。 如何让它运行故事板而不是.xibs? 我需要更改故事板中的部分,还是每个.xibs .h和.m的代码中都有?
感谢您的帮助
答案 0 :(得分:1)
查看您的App Delegate。以下是根据目标条件设置为与XIBS或Storyboard一起运行的示例...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FORMAT_XIB
NSLog (@"XIB VERSION");
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CVViewController* myViewController = nil;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
myViewController = [ [CVViewController alloc] initWithNibName:@"CVViewController_iPhone" bundle:nil ];
} else {
myViewController = [ [CVViewController alloc] initWithNibName:@"CVViewController_iPad" bundle:nil ];
}
self.window.rootViewController = myViewController;
[self.window makeKeyAndVisible];
#else
NSLog (@"STORYBOARD VERSION");
#endif
return YES;
}
如果您正在运行Storyboard应用程序,则不需要所有这些。删除它,以便应用程序didFinishLaunchingWithOptions:方法只读:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}