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. 基于深度学习的花卉图像关键点检测
  2. spring中@Transaction注解解析
  3. window下jansson安装和使用
  4. 什么是Handler(二)
  5. when is extAddTo.controller.js loaded
  6. CentOS6.5安装MySQL5.7详细教程
  7. leetcode 222. 完全二叉树的节点个数(dfs)
  8. 华强北耳机版本太多,不知道如何选购?
  9. python多分类_python中多类分类的ROC或CAP曲线
  10. DataBase -- Operator
  11. nw.js桌面软件开发系列 第0.1节 HTML5和桌面软件开发的碰撞
  12. openstack 之 kolla安装镜像
  13. 浅谈-61850-1
  14. html在按钮中加图片,在html里面怎么为一个按钮添加图片
  15. 2021 Hexo+Next7最全搭建个人网站(合集)
  16. 动手实现简易端口扫描器——PortScanner
  17. delphi fastreport4.5 的使用
  18. 密码学—安全归约问题(Reduction)
  19. 出战卡不足_特种部队TCG的不足之处和改进方案
  20. PDF如何设置注释字体大小

热门文章

  1. 华为路由器console口加密 telnet远程登录 DHCP server在路由器中的两种写法
  2. 蒲慕明院士:脑机融合技术或许会成为未来人工智能的一个热门方向
  3. 阿里p9教你Java学到什么程度才能叫精通?
  4. 软件工程课程设计——技术栈【Go+Vue+PGSQL】的人事管理系统
  5. 情人节程序员用HTML网页表白【情人节表白网页】 HTML5七夕情人节表白网页源码 HTML+CSS+JavaScript
  6. 如何做网站推广-外链为皇
  7. DDD实战课(实战篇)--学习笔记
  8. 网站静态化——前后端分离(下)
  9. Android音视频方向进阶路线及资源合集
  10. 为李想打call,谋局汽车,美团王兴的外卖终极战竟在这里