zoukankan      html  css  js  c++  java
  • iOS 13适配

    1. 安装时,加入Xcode11.3 后 原xcode会安装开发工具插件时候出现

    点击安装插件之后会出现

    目前没找到解决方案。只能在一个mac电脑上安装使用一个版本。

    2.编译时,会出现libstdc++.6.0.9.tbd 文件找不到的错误提示,需要将文件重新放入工程c++文件目录下。

    3.运行时,会出现另一个错误:

    NSInteger numberOfBeforeSection = [_update[@""] numberOfItemsInSection:updateItem.indexPathBeforeUpdate.section];
    
    

    此方法目前在Xcode11.3里调用UICollectionView方法需要强转成系统类名,即在_update[@""]加入(UICollectionView *)即可。
    如下

    NSInteger numberOfBeforeSection = [(UICollectionView *)_update[@""] numberOfItemsInSection:updateItem.indexPathBeforeUpdate.section];
    

    4.接下来就是比较关注的适配暗黑模式了:建议暂时直接关闭暗黑模式,如果有需求时再添加。

    //配置方式有两种,单页面配置 和 全局配置
        if (@available(iOS 13.0, *)) {
            self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
        }
    单页配置
        将需要配置的 UIViewControler 对象的 overrideUserInterfaceStyle 属性设置成 UIUserInterfaceStyleLight 或者 UIUserInterfaceStyleDark 以强制是某个页面显示为 浅/深色模式
     
        全局配置
        在工程的Info.plist的中,增加/修改 UIUserInterfaceStyle为UIUserInterfaceStyleLight或UIUserInterfaceStyleDark
    ————————————————
    

    5.UISearchBar的页面crash (可能出现,目前项目中未暴露出来)

    因为这一句代码:

    UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];
    

    需要进行ios 13的适配工作demo如下

    NSString *version = [UIDevice currentDevice].systemVersion;
          if (version.doubleValue >= 13.0) {
              // 针对 13.0 以上的iOS系统进行处理
              UITextField *searchField;
              NSUInteger numViews = [self.searchBar.subviews count];
              for(int i = 0; i < numViews; i++) {
                 if([[self.searchBar.subviews objectAtIndex:i] isKindOfClass:[UITextField class]]) {
                     searchField = [self.searchBar.subviews objectAtIndex:i];
                 }
              }
              if (searchField) {
                //这里设置相关属性
              }else{}
             
     
          } else {
              // 针对 13.0 以下的iOS系统进行处理
              UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];
                 
                 if(searchField) {
                    //这里设置相关属性
                     
                 }else{}
    }
    

    以下问题暂时项目中未发现,如出现可参照以下方式更改。

    6.uitextfield setvalue forkeypath方法失效

    该方法在iOS13已经无效,系统禁止通过KVC访问。会导致直接崩溃。修改方法使用textfild 的 attributePlaceholder属性即可。

    7.所有present的界面都会类似于sarfari网页视图一样的层叠方式显示。会导致项目部分页面无法横屏 返回无法刷新。在ios 13 里修改了vc的modalPresentationStyle的默认值为 -2

    要想解决这个问题很简单。直接设置present的vc模式为UIModalPresentationFullScreen(0)即可解决。变更后就会变成之前的跳转模式了。

    8.Sign In with Apple

    在iOS 13里添加了Sign In with Apple登录方式,根据苹果官网说明,2020年4月份之前需要所有第三方登录的app都需要更新,否则会拒审。具体可看苹果审核规则中的4.8章节。
    更新细节可以参考这篇文章Sign In with Apple

    9.statusbar修改背景色问题

    iOS13 已经去掉了这个方式。

    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    

    新的替换方案为:

    -(UIView *)statusBarUIview{
        if(@available(iOS 13,*)){
            
            int tag = 13004352;
            
            UIWindow *window = [UIApplication sharedApplication].delegate.window;
            UIView *view = [window viewWithTag:tag];
            if (view) {
                return view;
            }else{
                CGRect statusBarRect = [UIApplication sharedApplication].statusBarFrame;
                UIView *statusBarView = [[UIView alloc]initWithFrame:statusBarRect];
                statusBarView.tag = tag;
                [window addSubview:statusBarView];
                return statusBarView;
            }
        
        }else{
            UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
            if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
                return statusBar;
            }
        }
        
        return nil;
    }
    

    10.子线程修改界面导致崩溃(比如相册首次授权回调必现,二次授权偶现)

    在使用相册时我们会调用 [PHPhotoLibrary requestAuthorization:] 方法获取权限,获取的结果会通过一个带有PHAuthorizationStatus 信息的 block 进行回调。
    解决方案:在 Xcode 中调试运行时,子线程修改界面会有紫色感叹号标出,注意修改成回到主线程即可。

  • 相关阅读:
    String类的常用成员方法
    String类和StringBuffer类
    记事本
    GridLayout 可使容器中的各个组件呈网格状布局
    在使用add()方法添加组件到容器时,必须指定将其放置在哪个区域中
    每个容器都有一个布局管理器
    框架一般用作Java应用程序的窗口,而Applet是Java小程序的窗口
    面板是一种透明的容器,没有标题和边框
    要生成一个窗口,通常使用Window的子类Frame类进行实例化
    分布式系统 (大规模分布式系统原理解析和架构实践)
  • 原文地址:https://www.cnblogs.com/lovemargin/p/12123318.html
Copyright © 2011-2022 走看看