xCode删除storyboard,新建window并启动

application:didFinishLaunchingWithOptions该函数是应用程序启动之后首次加载页面的函数,删除storyboard之后,需要在这里new出新的window,初始化,并将其置为当前状态下的key window并展示之。

第一步:删除storyboard,建立一个xib文件。

第二步:如下图所示,点击对应的xib文件-》File's Owner-》show the identify inspector(绿圈圈出的位置)

将Custom Class的class名称改为对应的类名,与相关类关联起来。

第三步:点击工程名,将Deployment info-》General中的Main Interface置为空

第四步:将xib文件的view与view属性相关联

第五步:设置应用程序代理

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//程序启动之后执行,只在第一次启动后执行,以后不再执行。
//删除storyboard之后,需要在这里new出一个新的window,将该window初始化后,置为该应用程序的keywindow并展现出来。
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor]; ViewController *root = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; //加载nib文件,生成View实例
[self.window setRootViewController:root]; //将new出来的view实例设置为window的root view。 [self.window makeKeyAndVisible]; //将当前winsow置为当前状态下的key window,并呈现出来。Makes the receiver the key window and visible.
return YES;
}
上一篇:SVN提交错误:working copy is not up-to-date解决方法


下一篇:Redis连接出现Error: Connection reset by peer的问题是由于使用Redis的安全模式