Xcode6.4下代码新建启动界面
1、新建一个Single View Application ,并命名。

2.创建好后
选中项目名称,在配置栏中选择Info栏目,在Custom iOS Target Properties子栏目中删除Main storyboard file base name项(即点击“-”号按钮即可):

3.删除xxxViewController的.h和.m文件,并删除Main.storyboard文件;

4.创建根视图控制器
例如名称为XXXViewController(名称自己定义):在项目名称上右键选择New File,在iOS栏目中,选择Source子栏目,选中Cocoa Touch Class类型的模板,点击Next,在Class项中输入控制器文件名称XXXViewController,选中Also create XIB file,点击Next,点击Create。


生成三个文件

5.在AppDelegate.m文件中

找到didFinishLaunchingWithOptions方法,清理方法体内容;

编辑删除后的内容修改如下:(即AppDelegate.m中的文件内容)

#import"AppDelegate.h"
#import"XXXViewController.h"
@interfaceAppDelegate()
@end
@implementationAppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
self.window= [[UIWindowalloc]initWithFrame:[UIScreenmainScreen].bounds];
//第一个视图控制器
XXXViewController*rootVC = [[XXXViewControlleralloc]init];
//将第一个视图控制器作为基栈视图控制器添加到导航视图控制器中
UINavigationController*navCtr = [[UINavigationControlleralloc]initWithRootViewController:rootVC];
//将导航视图控制器作为根视图控制器
self.window.rootViewController= navCtr;
[self.windowmakeKeyAndVisible];
returnYES;
}
@end
6.在XXXViewController中的viewWillAppear方法中添加标题与背景颜色:

#import"XXXViewController.h"
@interfaceXXXViewController()
@end
@implementationXXXViewController
- (void)viewDidLoad
{
[superviewDidLoad];
self.title=@"XXX";
self.view.backgroundColor= [UIColorgrayColor];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
}
-(void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
//添加标题
self.navigationItem.title=@"XXXViewController";
}
@end
最后运行结果
