iOS13适配

作者: boy丿log | 来源:发表于2019-10-08 09:33 被阅读0次

随着2019年苹果发布会的发布,iPadOS与iOS13也带来了新的架构体系,那就是以UIScene为核心的分屏概念。在iOS9之后,ipad不同的应用间是可以多开的,而在iOS13和ipadOS系统中,同一应用也支持多开。新系统之前,UIAppication管理者app和UI的生命周期,而新版本之后,UIAppication则更加专心的负责app的生命周期,而UI的管理则放在了UIWindowScene中,与之对应的是,UIAppication的Delegate中所有与UI有关的方法和属性都移除了(或者说不建议被使用)。

即使你的app没有适配分屏,但是在iOS13中也会被UIScene所管理,但是还会走原来的回调。

部分变化的API

当然,这只是一部分。

而,UIAppication中所有有关window的属性如:

@property(nullable, nonatomic,readonly) UIWindow *keyWindow API_DEPRECATED("Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes", ios(2.0, 13.0));
@property(nonatomic,readonly) NSArray<__kindof UIWindow *>  *windows;

- (BOOL)sendAction:(SEL)action to:(nullable id)target from:(nullable id)sender forEvent:(nullable UIEvent *)event;

@property(nonatomic,getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible API_UNAVAILABLE(tvos) API_DEPRECATED("Provide a custom network activity UI in your app if desired.", ios(2.0, 13.0));

@property(readonly, nonatomic) UIStatusBarStyle statusBarStyle API_UNAVAILABLE(tvos) API_DEPRECATED("Use the statusBarManager property of the window scene instead.", ios(2.0, 13.0)); // default is UIStatusBarStyleDefault

@property(readonly, nonatomic,getter=isStatusBarHidden) BOOL statusBarHidden API_UNAVAILABLE(tvos) API_DEPRECATED("Use the statusBarManager property of the window scene instead.", ios(2.0, 13.0));

@property(readonly, nonatomic) UIInterfaceOrientation statusBarOrientation API_UNAVAILABLE(tvos) API_DEPRECATED("Use the interfaceOrientation property of the window scene instead.", ios(2.0, 13.0));

都在新系统中废弃。

具体的可以去了解一下关于UIScene更多的知识这里不再多讲。

但是UIAppication给出两个属性:

#pragma mark -- UIScene --
// All of the currently connected UIScene instances
@property(nonatomic, readonly) NSSet<UIScene *> *connectedScenes API_AVAILABLE(ios(13.0));

// All of the representations that currently have connected UIScene instances or had their sessions persisted by the system (ex: visible in iOS' switcher)
@property(nonatomic, readonly) NSSet<UISceneSession *> *openSessions API_AVAILABLE(ios(13.0));

// returns YES if the application both declares multiple scene support in its info.plist and the executing environment allows multiple scenes for at least one system type. NO otherwise.
@property(nonatomic, readonly) BOOL supportsMultipleScenes API_AVAILABLE(ios(13.0));

可以看到我们得到的scene是一个集合.

那么我们如果在数据模型中要使用到showWindow属性的时候如何获取呢?

我的一个解决方法是hook UIWindow的这个方法:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;

1.记录操作window

在每一次点击UIView的时候,通过UIView的window属性获取当前操作的window,记录下来。

2.获取window

在获取window的时候遍历connectedScenes,如果只有一个scene处于前台,当前在前台的window处理事件的优先级最高,当做showWindow,其他的我们就用上次操作的window来处理事件。

相关文章

  • iOS13 适配问题 看这一篇就够了

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • iOS 13适配

    技术参考: apple login IOS13适配-详细 iOS 13 适配(持续更新中) iOS13适配 掘金 ...

  • 暗黑模式开发

    iOS13暗黑模式适配(项目开发版) iOS 13 DarkMode 暗黑模式 IOS 暗黑模式适配---基础适配

  • iOS13适配更新总结

    前言: iOS13的API的变动和适配问题,我从新特性适配、API 适配、方法弃用、工程适配、SDK 适配、其他问...

  • iOS13适配研究

    iOS13今年秋季会发布,最近深入研究了下公司APP适配iOS13的注意点,适配如下。 1.由于Xcode10移除...

  • iOS13适配

    参考: iOS13 适配踩坑 - 持续更新 iOS 13 适配要点总结 iOS 13 适配要点总结 1、prese...

  • iOS13适配(更新中)

    对于iOS13适配汇总以及遇到的问题注意:以下适配内容,必须适配的会以"必须"标出 1. Dark Model(必...

  • 关于WRNavigationBar iOS12、iOS13导航栏

    集成WRNavigationBar 适配iOS12 iOS13导航栏问题 在修复iOS13下在iPhone11机型...

  • 关于WRNavigationBar iOS12、iOS13导航栏

    集成WRNavigationBar 适配iOS12 iOS13导航栏问题 在修复iOS13下在iPhone11机型...

  • 2019--09iOS13适配

    iOS13适配iOS13更新后对Ai定损、一车一件项目进行适配 做了一下调查 1 2 3 4 5 6 目前调研的只...

网友评论

    本文标题:iOS13适配

    本文链接:https://www.haomeiwen.com/subject/defydctx.html