方法一

心急的童鞋按照老操作完成后再按照如下操作即可

/**
弃用storboard
1、info.plist去除
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
2、启动页注释
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
} - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
*/

具体如下:

用xcode11新建iOS项目后,想要删除默认的main.storyboard,使用自定义的window和controller的坑。

具有一定经验的人想必都知道Xcode11之前,想要达到上面的目的步骤吧。首先就是选中工程文件选项,之后删除Main Interface选项里的Main,如下图:

 
 

之后在Appdelegate的didFinishLaunchingWithOptions方法中自定义window并设置为keyWindow和让它显示,如下图:

 
 

就这么简单的实现了。

然鹅随着iOS13的推出,在之前AppDelegate的基础上多出了一个SceneDelegate,会将AppDelegate里的lifecycle的那些代理方法转交给SceneDelegate,就是通过AppDelegate里以下两个方法实现的

 
 

以下的内容是摘自苹果官方文档:

Overview

A UISceneSession object manages a unique runtime instance of your scene. When the user adds a new scene to your app, or when you request one programmatically, the system creates a session object to track that scene. The session contains a unique identifier and the configuration details of the scene. UIKit maintains the session information for the lifetime of the scene itself, destroying the session in response to the user closing the scene in the app switcher.

You do not create session objects directly. UIKit creates sessions in response to user interactions with your app. You can also ask UIKit to create a new scene and session programmatically by calling the requestSceneSessionActivation:userActivity:options:errorHandler: method of UIApplication. UIKit initializes the session with default configuration data based on the contents of your app's Info.plist file.

大概意思就是,一个UISceneSession不用你直接去创建对象,你可以用UIApplication里的requestSceneSessionActivation:userActivity:options:errorHandler:方法,这个方法会帮你初始化一个基于info.plist文件里的默认configuration的session对象。

因此xcode11中要实现自己的没有默认main.storyboard的项目,就得将SceneDelegate里的lifecycle转交给AppDelegate,按照上面所说,这一步操作就是,删除或注释一下截图里的两个方法

 
 

接近着删除在info.plist里的Application Scene Manifest条目

 
 

之后就是xcode11以前的常规操作了,首先,删除info.plist里的Main storyboard file base name条目

 
 

之后在AppDelegate.swift里添加window属性,因为xcode默认删除了这个属性,现在你需要将它重新添加回来才行,如果是OC写的话,就在AppDelegate.h里添加这个window属性。

 
 

之后就在didFinishLaunch方法里初始化self.window,并设置为keywindow和让它显示,并初始化默认控制器即可。

 方法二
Xcode自动新增了一个SceneDelegate文件, 也就是说在iOS13中Appdelegate的作用发生了改变: iOS13之前,Appdelegate的作用是全权处理App生命周期和UI生命周期; iOS13之后,Appdelegate的作用是只处理 App 生命周期, 而UI的生命周期将全权由新增的SceneDelegate来处理.
 
SceneDelegate.m中的方法只有iOS13之后才能使用, 如果新建的项目要兼容之前的版本, 就需要自己在SceneDelegate和Appdelegate中做判断
 

首先, UI相关的已经不能只放在Appdelegate中, 而是区分系统放在SceneDelegate中处理.

其次, 要在Info.plist中删除对应的路径.

最后, 在SceneDelegate.m中添加根控制器

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). self.window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootVc = [[UIViewController alloc]init];
rootVc.view.backgroundColor = [UIColor purpleColor];
UINavigationController *rootNav = [[UINavigationController alloc]initWithRootViewController:rootVc];
[self.window setRootViewController:rootNav];
[self.window makeKeyAndVisible];
}

xcode11新项目删除main.storyboard 两种方法的更多相关文章

  1. web项目docker化的两种方法

    标题所讲的两种方法其实就是创建docker镜像的两种方法 第一种:启动镜像后进入容器中操作,将需要的软件或者项目移动到容器中,安装或者部署,然后退出即可 第二种:编写dockerfile,将需要的镜像 ...

  2. MySQL中删除数据的两种方法

    转自:http://blog.csdn.net/apache6/article/details/2778878 1. 在MySQL中有两种方法可以删除数据: 一种是delete语句,另一种是trunc ...

  3. ASP.NET中GridView控件删除数据的两种方法

      今天在用GridView控件时,发现了一个问题,就是使用GridView控件在删除数据时的问题.接下来我们通过模板列方式和CommandField方式删除某条数据讲解下两者之间的区别. 方式一:通 ...

  4. MySQL 删除数据库的两种方法

    使用 mysqladmin 删除数据库 使用普通用户登陆mysql服务器,你可能需要特定的权限来创建或者删除 MySQL 数据库. 所以我们这边使用root用户登录,root用户拥有最高权限,可以使用 ...

  5. create-react-app创建项目修改配置项的两种方法

    方法一:eject 打开 package.json ,可以看到eject.运行 npm run eject 可以让由create-react-app创建的项目的配置项暴露出来. { ... " ...

  6. 解决vue项目eslint校验 Do not use 'new' for side effects 的两种方法

    import Vue from 'vue' import App from './App.vue' import router from './router' new Vue({ el: '#app' ...

  7. js中如何删除某个元素下面的所有子元素?(两种方法)

    js中如何删除某个元素下面的所有子元素?(两种方法) 一.总结 方法一:通过元素的innerHTML属性 元素element.innerHTML=""; 方法二:通过元素的remo ...

  8. 关于vector的erase删除操作的两种不同方法,在linux与visual studio的实现讨论

    关于vector的erase删除操作的两种不同方法,在linux与visual studio的实现讨论 1.前言: 最近在做某一个题时,用到了vector的删除操作,利用的是erase()函数删除符合 ...

  9. Response.Redirect 打开新窗体的两种方法

    普通情况下,Response.Redirect 方法是在server端进行转向,因此,除非使用 Response.Write("<script>window.location=' ...

随机推荐

  1. 201871010112-梁丽珍《面向对象程序设计(java)》第四周学习总结

    项目 内容 这个作业属于哪个课程 <任课教师博客主页链接>https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 <作业链接地址>http ...

  2. 火车头data下任务文件夹的SpiderResult.db3文件用什么软件打开

    火车头采集器默认是用sqlite数据库来保存数据的,新建一个采集,打开data/任务/发现有一个SpiderResult.db3文件,.db3是sqlite的存储文件后缀,那么要如何查看这些文件呢?用 ...

  3. Maven 中 dependencyManagement 标签使用

    1.在Maven中dependencyManagement的作用其实相当于一个对所依赖jar包进行版本管理的管理器. 2.pom.xml文件中,jar的版本判断的两种途径 1:如果dependenci ...

  4. NOIP 2006 明明的随机数

    洛谷 P1059 明明的随机数 洛谷传送门 JDOJ 1423: [NOIP2006]明明的随机数 T1 JDOJ传送门 Description 明明想在学校中请一些同学一起做一项问卷调查,为了实验的 ...

  5. 2.1 自动内存管理机制--Java内存区域与内存溢出异常

    自动内存管理机制 第二章.Java内存区域与内存溢出异常 [虚拟机中内存如何划分,以及哪部分区域.什么样代码和操作会导致内存溢出.各区域内存溢出的原因] 一.运行时数据区域 Java虚拟机所管理的内存 ...

  6. Pandas之csv文件对列行的相关操作

    1.Pandas对数据某一列删除 1.删除列 import pandas as pd df = pd.read_csv(file) #axis=1就是删除列 df.drop(['列名1','列名2'] ...

  7. C函数之genv

    函数原型: include<stdlib.h> char *getenv(char *envvar); 函数说明: getenv()用来取得参数envvar环境变量的内容.参数envvar ...

  8. javascript系列--认识并理解构造函数,原型和原型链

    一.前言 介绍构造函数,原型,原型链.比如说经常会被问道:symbol是不是构造函数:constructor属性是否只读:prototype.[[Prototype]]和__proto__的区别:什么 ...

  9. [Gamma阶段]展示博客

    水哥牛X团队[Gamma阶段]展示博客 微信小程序搜索"小小易校园"即可体验 项目愿景 想参加竞赛,锻炼自己,却找不到合适的队友 想进行实习,体验工作,每天不得不翻遍吐槽版的几百条 ...

  10. SpringBoot 系列教程 JPA 错误姿势之环境配置问题

    191218-SpringBoot 系列教程 JPA 错误姿势之环境配置问题 又回到 jpa 的教程上了,这一篇源于某个简单的项目需要读写 db,本想着直接使用 jpa 会比较简单,然而悲催的是实际开 ...