• iOS16适配


    1、横竖屏切换

    [UIDevice currentDevice] 使用setValue:forKey:的方式在iOS16上面已经不可用,继而要使用UIWindowScene里面的函数请求

    1. if (@available(iOS 16.0, *)) {
    2.     UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
    3.     UIWindowSceneGeometryPreferencesIOS *perference = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
    4.     perference.interfaceOrientations = 1 << deviceOrientation;
    5.     [windowScene requestGeometryUpdateWithPreferences:perference errorHandler:^(NSError * _Nonnull error) {
    6.         NSLog(@"error--%@", error);
    7.     }];
    8. } else {
    9.         [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:deviceOrientation] forKey:@"orientation"];
    10.         [UIViewController attemptRotationToDeviceOrientation];
    11. }
    12. 复制代码

    1.1、屏幕旋转通知在iOS16无法处触发

    需要重写UIViewController的viewWillTransitionToSize:withTransitionCoordinator:,在此函数里面处理UI。

    1.2、iOS16 使用过YYTextView之后无法旋转屏幕

    使用过UITextView之后,再调用函数 requestGeometryUpdateWithPreferences:geometryPreferences errorHandler: 请求无效,无法旋转屏幕

    分析: 打印所有的connectedScenes

    使用YYTextView之前

    使用YYTextView之后

    问题是当前的UIWindowScene里面多了一层YYTextView添加的YYTextEffectWindow,去掉这一层window就可以了。

    2、xcode14 UIViewController在dealloc时发生崩溃

    iOS16调试的时候报错

    Application circumvented objective-c runtime dealloc initiation for <%s> object并崩溃

    原因是: IOS16 苹果不允许重写系统控件分类(Categroy)中重写 + (void)initialize方法

    3、使用xcode14打出来的包,在iOS12.2以下的系统发生崩溃

    使用otool工具查看二进制文件发现

    二进制里面多了一个 /usr/lib/swift/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 120.100.0)

    解决方法:

    Build Phases -> Link Binary With Librarires 里面添加libswiftCoreGraphics.tbd

    Apple Recommended(苹果推荐的解决方法)

    xcode14 解决方法:

    1. Build Setting -> other link flags 添加 -Wl,-weak-lswiftCoreGraphics
    2. 复制代码

    4、如果UINavigationItem的titleView有自动布局,UI布局展示错误

    1. extension UINavigationItem {
    2. func addView(_ view: UIView, _ color: UIColor = .clear) {
    3. if #available(iOS 13, *) {
    4. let tempTitleV = UIView()
    5. tempTitleV.backgroundColor = color
    6. tempTitleV.frame = CGRect(x: 0, y: 0, width: App.screenWidth - 100, height: App.navigationBarHeight)
    7. self.titleView = tempTitleV
    8. tempTitleV.addSubview(view)
    9. view.snp.makeConstraints { make in
    10. make.center.equalToSuperview()
    11. make.height.equalTo(App.navigationBarHeight)
    12. make.width.equalTo(App.screenWidth - 100)
    13. }
    14. } else {
    15. self.titleView = view
    16. }
    17. }
    18. }

    相关链接:Apple Forums 链接

  • 相关阅读:
    大数据学习初级入门教程(十五) —— Redis 在 Windows 系统上的安装、配置、启动和测试
    (有代码示例)Vue 或 JavaScript中使用全局通信的3种方式
    JVM调优相关命令以及解释
    io+day8
    11.22Spring 学习day02
    Zabbix Timeout 设置不当导致的问题
    八股文学习三(jvm+线程池+锁)
    【月报】Aavegotchi 开发进度更新 - 2023 年 8 月
    ONNX--学习笔记
    【SpringBoot】多环境配置和启动
  • 原文地址:https://blog.csdn.net/Arodung/article/details/127443184