方法一

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

/**弃用storboard1、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. linux 批量删除进程的两种方法

    linux批量删除进程的两种方法 介绍两种方法.要kill的进程都有共同的字串. [plain]  kill -9 `ps -ef |grep xxx|awk '{print $2}' `    ki ...

  2. linux删除用户删不了怎么办,Linux下完全删除用户的两种方法

    Linux操作 实验环境:Centos7虚拟机 首先创建一个普通用户 gubeiqing . [root@localhost ~]# useradd gubeiqing [root@localhost ...

  3. MySQL中删除数据的两种方法_MySQL删除数据库的两种方法

    本文为大家分享了两种MySQL删除数据库的方法,供大家参考,具体内容如下 第一种方法:使用 mysqladmin 删除数据库使用普通用户登陆mysql服务器,你可能需要特定的权限来创建或者删除 MyS ...

  4. android字符串加删除线,android TextView 设置和取消删除线的两种方法

    一.TextView 设置删除线有两种方式: (推荐)方式一: 通过按位或运算符|,将 TextView 原本的 Flags 属性和删除线一块设置.setPaintFlags内会对 TextView ...

  5. mysql如何删除数据_MySQL中删除数据的两种方法

    1. 在MySQL中有两种方法可以删除数据: 一种是delete语句,另一种是truncate table语句. delete语句可以通过where对要删除的记录进行选择,而使用truncate ta ...

  6. SAP采购订单抬头、行项目屏幕增强的两种方法

    对SAP系统中采购订单抬头进行屏幕增强,在抬头上增加了几个customer fields,但是实现方法有点怪,是一个Z report程序,其下创建了一个屏幕,屏幕中放的就是这几个customer fi ...

  7. python入门小项目-判断闰年的两种方法(含代码示例)

    每当问到今年是不是闰年都先要思考一下再给出回答,一个年份的判断还好,多个问起来就得想一会了,虽然在网上也可以查,但在这里,还是和大家分享下用哪个Python怎么去帮我们快速做判断. 我们先搞清楚什么是 ...

  8. 批量删除记录的两种方法

    如果需要对数据记录进行批量删除,可借鉴使用如下方法: 将复选框的value设为表ID,递交后: 程序代码 conn.execute("delete from yourtable where  ...

  9. mysql删除库_MySQL 删除数据库的两种方法

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

最新文章

  1. java配置中心开源项目_配置中心搭建(spring-cloud-config-server)
  2. 作为一个程序员为什么要写博客?
  3. 全球及中国皮革和纺织品用甲酸行业竞争调查分析及投资规划报告2021年版
  4. java地图瓦片_百度地图瓦片层级范围对照表
  5. android 圆形选中,RoundChoiceView
  6. php劫持代码,利用php来嗅探劫持服务器数据
  7. android 流量统计工具,Android 统计应用流量的使用情况
  8. html语言 大全,HTML语言大全
  9. modbus_tk与Modubs Slave结合使用
  10. Spark Master资源调度--worker向master注册
  11. 简化异常处理的Throwables类
  12. Java程序员如何通过阿里、百度的招聘面试
  13. 【每日英文】2021.9.23
  14. 【HDFS】HDFS文件块大小(重点)
  15. 项目实战-----产品经理要做什么?
  16. 还只会用小黄鸭解压?看来你不是一个时髦的程序员!
  17. laravel 使用SSH 隧道连接到远程数据库
  18. MySQL之索引,执行计划及SQL优化
  19. Sentinel 流控(限流)
  20. android 实现控件搜索折叠效果 Animation动画折叠和普通折叠

热门文章

  1. 【NLP基础理论】03 文本分类
  2. jeesite代码生成id出不来的解决方案
  3. 数字电路技术可能出现的简答题_电子技术应用实验1(数字电路基础实验)答案公众号...
  4. 盲盒包装流水线 (25 分) C语言
  5. 没想到钱多多的求职之路竟如此艰辛,求大佬指点
  6. flppy bri_BRI的完整形式是什么?
  7. C4D-学习笔记-4-渲染(ProRender渲染介绍)
  8. 常见数据库与数据引擎概念(一)
  9. 12月30日学习总结
  10. 【PC工具】chrome谷歌浏览器各种版本,最好用的浏览器没有之一。低调使用福利...