iOS13之后,xcode 11新建项目,大家会发现项目中多出了SceneDelegate这个类,而且新建项目之后,在模拟器上运行没问题,真机上低于iOS13系统的手机就会出现黑屏(解决方法就是在AppDelegate.h中按照以前的方法添加一个UIWindow *window的属性即可,因为iOS13以下根本没有UIScene这一层),而后看了代码发现,

image.png,

在AppDelegate.h中少了@property (strong, nonatomic) UIWindow * window;

image.png,

AppDelegate.m中也少了一些生命周期方法

image.png,

反观之SceneDelegate中,window被放在了SceneDelegate.h中,而一些生命周期跑到了SceneDelegate.m中

#import "SceneDelegate.h"

@interface SceneDelegate ()

@end

@implementation SceneDelegate

- (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).

}

- (void)sceneDidDisconnect:(UIScene *)scene {

// Called as the scene is being released by the system.

// This occurs shortly after the scene enters the background, or when its session is discarded.

// Release any resources associated with this scene that can be re-created the next time the scene connects.

// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).

}

- (void)sceneDidBecomeActive:(UIScene *)scene {

// Called when the scene has moved from an inactive state to an active state.

// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.

}

- (void)sceneWillResignActive:(UIScene *)scene {

// Called when the scene will move from an active state to an inactive state.

// This may occur due to temporary interruptions (ex. an incoming phone call).

}

- (void)sceneWillEnterForeground:(UIScene *)scene {

// Called as the scene transitions from the background to the foreground.

// Use this method to undo the changes made on entering the background.

}

- (void)sceneDidEnterBackground:(UIScene *)scene {

// Called as the scene transitions from the foreground to the background.

// Use this method to save data, release shared resources, and store enough scene-specific state information

// to restore the scene back to its current state.

}

@end

查了资料,看了看Apple的文档才知道,原来生命周期与window跑到了UIScene去管理了,它的出现是为了iPadOS的多进程准备的(可以同时开启多个相同App),现在的逻辑是用Appdelegate管理单个或多个UIScene,一个UIScene管理单个或多个UIWindow。

ios运行html时黑屏,iOS13 ,xcode11新建项目真机运行出现黑屏及新出现的SceneDelegate的作用...相关推荐

  1. 【小程序专栏】第一个uniapp项目编译到微信开发者工具以及android真机运行

    在本专栏之前的文章已经为大家介绍过,uniapp作为一个跨端开发框架被广泛应用.通过uniapp可以开发一套程序.运行到andoid.ios以及各种小程序端,微信小程序.支付宝小程序.百度小程序.字节 ...

  2. iOS常见问题笔记总结这是本人开发中遇见的一些常见问题处理方法的总结笔记,包括http访问配置、Alcatraz插件安装、最新cocoapod安装、真机运行出错等许多与参考笔记总结,希望对大家有所帮助

    开发总结: 快捷键打开浏览器控制台cmd+option+J 强制退出任务或者打开任务栏:command+option+SSC(打开任务栏):command+option+shift+ESC(强制退出任 ...

  3. Appium自动化测试-iOS真机运行

    在使用iOS真机运行之前,需要配置好WDA,如果没有安装配置好WDA,可以参考文章:https://blog.csdn.net/dou_being/article/details/107745463 ...

  4. 电脑显示没有被指定在上运行_win7运行QQ时出现“.dll没有被指定在Windows上运行,或者它包含错误”如何解决...

    最近有用户在win7系统中运行QQ的时候出现".dll没有被指定在 Windows 上运行,或者它包含错误.请尝试使用原始安装媒体重新安装程序,或联系您的系统管理员或软件供应商以获取支持.& ...

  5. ios 真机运行:The app ID cannot be registered to your development team

    问题背景: 我的mac笔记本总是空间不足,我就按网上的删掉了很多library下xcode相关的库,居然腾出60多G,过了一个月后,我需要再次调试时,发现之前能在真机上跑的app,跑不了了,报错如下: ...

  6. Hbuilder 真机运行显示未受信任的解决方法(ios)

    Hbuilder 真机运行显示未受信任的解决方法(ios) 参考文章: (1)Hbuilder 真机运行显示未受信任的解决方法(ios) (2)https://www.cnblogs.com/wenx ...

  7. ionic+vue+capacitor系列笔记--02项目中集成Capacitor,添加android,ios平台,真机运行项目

    Capacitor是什么? Capacitor是由ionic团队开发的一款跨平台移动应用构建工具,可轻让我们轻松的构建Android.iOS.Electron和Web应用程序. Capacitor是A ...

  8. 电脑显示没有被指定在上运行_win10系统运行QQ时出现“.dll没有被指定在windows上运行,或者它包含错误”的解决教程...

    win10系统使用久了,好多网友反馈说win10系统运行QQ时出现".dll没有被指定在windows上运行,或者它包含错误"的问题,非常不方便.有什么办法可以永久解决win10系 ...

  9. 模拟器和真机运行都是屏幕上下有黑边的解决方法

    模拟器和真机运行都是屏幕上下有黑色边框. 解决办法,就是准备一张分辨率超过1136*640大小的图片,命名Default-568h@2x.png 然后将文件添加到项目中,不用做任何配置,运行后就发现屏 ...

最新文章

  1. 德扑 AI 之父解答 Libratus 的13个疑问:没有用到任何深度学习,DL 远非 AI 的全部
  2. 设计模式(十五):Iterator迭代器模式 -- 行为型模式
  3. open***配置成功分析(服务器)
  4. select报错 spark_使用spark-sql报错 “Metastore contains multiple versions”
  5. sklearn 随机分割数据_sklearn.ensemble.RandomForestClassifier 随机深林参数详解
  6. html配置ss,#WEB安全基础 : HTML/CSS | 0x8CSS进阶
  7. python #!/usr/bin/python作用
  8. 神秘的Windows7 Send To
  9. 深度学习笔记(二):简单神经网络,后向传播算法及实现
  10. var模型eviews操作步骤
  11. 【总结】最近写代码的思考与总结
  12. 【MYSQL】mysql.sock连接问题
  13. 慧数纵览:日产在华三大工厂将减产30,000辆
  14. C语言n层嵌套平方根的计算n
  15. 哔哩哔哩第三方神器软件,早该用上了
  16. 最新青龙拉库命令及监控变量教学
  17. 硬件设计—数字电路常用设计准则
  18. ios 按钮下面加下划线_iOS开发UILabel和UIButton添加下划线
  19. 旷视创始人印奇被司机敲诈300万元未遂:“我有公司敏感信息录音”
  20. 项目管理(四):项目整合管理

热门文章

  1. 南非醉茄来源的天然产物之活性大盘点
  2. Java程序员职场全功略 从小工到专家 连载三 IT语言平台
  3. C语言 - 比较字符串大小
  4. 从零玩转第三方登录之WeChat公众号登陆-cong-ling-wan-zhuan-di-san-fang-deng-lu-zhi-wechat-gong-zhong-hao-deng-lu...
  5. e-人事管理系统-人事档案-变更管理-人员职务变更
  6. java计算机毕业设计恒美服饰原材料采购预约配送系统MyBatis+系统+LW文档+源码+调试部署
  7. Java基础学习笔记4
  8. win10电脑前面板耳机无声音
  9. linux中 bash_profile,Linux中profile、bashrc、bash_profile区别
  10. 【H - Pots】