我不想使用故事板,而更喜欢在必要时使用 NIB 来构建用户界面,尤其是在默认模板中不想使用它们。
Xcode 5 不再有“不使用 Storyboards”复选框,
有人可以帮忙吗?这真的很烦人...
去除故事板的步骤 - XCode 5 (编辑)
1/ 创建一个空项目
2/ 添加带有xib文件的控制器,如果它没有在编译源中添加到构建阶段,则手动添加。
4) 更改appdelegate didFinishLaunchingWithOptions文件并添加:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
[self.window makeKeyAndVisible];
就像:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
移除故事板的步骤
1)从您的项目中删除Main.storyboard文件。
2)为您的控制器添加具有xib的新文件,如果它没有添加到编译源中,则手动添加到构建阶段中。
3)从plist中删除Main storyboard文件的基本名称。
4)更改appdelegate didFinishLaunchingWithOptions文件并添加:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
[self.window makeKeyAndVisible];
就像:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
看一下这里