• Xcode11.1 踩坑备忘录


    Xcode11.1 踩坑备忘录(mac系统10.15)

    1 、环信ChatDemo2.0报错

    这是环信ChatDemo2.0报错

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

    改为

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

    2、暗黑模式暂时不适配的处理

    全局配置 在工程的Info.plist的中,增加/修改 UIUserInterfaceStyle为UIUserInterfaceStyleLight或UIUserInterfaceStyleDark

    3、library not found for -lstdc++.6.0.9

    这个在xcode 10也存在的问题,采用大佬的方式处理,道理一样把需要的文件放到对应的路径下。不过大佬写了一个脚本,更方便

    Xcode 10和Xcode 11中删除的libstdc++库    https://github.com/devdawei/libstdc-

    4、present到登录页面时,发现新页面不能顶到顶部

    原因是iOS 13 多了一个新的枚举类型 UIModalPresentationAutomatic,并且是modalPresentationStyle的默认值。

    UIModalPresentationAutomatic实际是表现是在 iOS 13的设备上被映射成UIModalPresentationPageSheet。

    但是需要注意一点PageSheet 与 FullScreen 生命周期并不相同 FullScreen会走完整的生命周期

    ,PageSheet因为父视图并没有完全消失,所以viewWillDisappear及viewWillAppear并不会走,

    如果这些方法里有一些处理,还是换个方式,或者用FullScreen

    设置方法:跟暗黑模式一样放到 push的时候或者根视图控制器 self.modalPresentationStyle = UIModalPresentationFullScreen;

     

    5、私有API被封禁(KVC限制),禁止访问

    1、获取SearchBar的textField

    由于在13中把SearchBar中的textField直接暴露给开发者使用,无需在通过kvc获取。

    if ([[[UIDevice currentDevice]systemVersion] floatValue] >=     13.0) {
    
               searchField = _vSearchBar.searchTextField;
    
        }else{
    
           searchField = [self valueForKey:@"_searchField"];
    
        }

    2、修改TextFiled的占位符字体大小以及颜色,在iOS13中不能通过KVC来进行修改,可以通过其属性字符串来进行修改

         [_phone setValue:C6 forKeyPath:@"_placeholderLabel.textColor"];

    UITextField *textfield = [[UITextField alloc]init];
    NSMutableAttributedString *arrStr = [[NSMutableAttributedString alloc]initWithString:textfield.placeholder attributes:@{NSForegroundColorAttributeName : [UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:12]}];
    textfield.attributedPlaceholder = arrStr;

    6、Sign in with Apple 第三方登录

     这个2020年4月前处理了就好

    想尝试可以参考https://www.jianshu.com/p/e1284bd8c72a

    7、即将废弃的 LaunchImage

    从 iOS 8 的时候,苹果就引入了 LaunchScreen,我们可以设置 LaunchScreen来作为启动页。

    当然,现在你还可以使用LaunchImage来设置启动图。

    不过使用LaunchImage的话,要求我们必须提供各种屏幕尺寸的启动图,来适配各种设备,随着苹果设备尺寸越来越多,这种方式显然不够 Flexible。

    而使用 LaunchScreen的话,情况会变的很简单, LaunchScreen是支持AutoLayout+SizeClass的,所以适配各种屏幕都不在话下。

    ⚠️从2020年4月开始,所有使⽤ iOS13 SDK的 App将必须提供 LaunchScreen,LaunchImage即将退出历史舞台。可以使用Launch Storyboards来进行解决。

    8、tabBarItem 选中状态的颜色无效,显示默认的蓝色

    以前只设置选中状态的颜色是可以的,现在可以这样设置

        [vc.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: MENU_ITEM_SELECTED_COLOR, NSForegroundColorAttributeName, nil] forState:UIControlStateSelected 
    
    if (@available(iOS 13.0, *)) {
            self.tabBar.tintColor = MENU_ITEM_SELECTED_COLOR;
    
        } else {
            [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: MENU_ITEM_SELECTED_COLOR} forState:UIControlStateSelected];
        }

    PS: xcode11 其他坑,我没踩到

    1、废弃 UISearchDisplayController

    在 iOS 8 之前,我们在 UITableView 上添加搜索框需要使用 UISearchBar + UISearchDisplayController 的组合方式,而在 iOS 8 之后,苹果就已经推出了 UISearchController 来代替这个组合方式。在 iOS 13 中,如果还继续使用 UISearchDisplayController 会直接导致崩溃

    2、增加一直使用蓝牙的权限申请

    CBCentralManager,iOS13以前,使用蓝牙时可以直接用,不会出现权限提示,iOS13后,再使用就会提示了。

    在info.plist里增加NSBluetoothAlwaysUsageDescription 我们要一直使用您的蓝牙,具体做什么别问我

    3、UISegmentedControl 默认样式改变

    默认样式变为白底黑字,如果设置修改过颜色的话,页面需要修改

    4、MPMoviePlayerController在iOS13中废弃

    MPMoviePlayerController is no longer available. Use AVPlayerViewController in AVKit.
    在iOS13中对于MPMoviePlayerController使用的废弃,需要使用AVKit中的AVPlayerViewController来达到播放的目的。

    参考: https://www.cnblogs.com/vlucht/p/11576294.html

    备注:

    解决MAC系统升级(10.15)导致COCOAPODS失效问题

    pod install 报错       sudo gem update --system 也不行  
    dunkhomedeMacBook-Pro:get dunkhome$ pod install
    -bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
    dunkhomedeMacBook-Pro:get dunkhome$ sudo gem update --system
    ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
        bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

    居然是404,于是我用浏览器打开https://gems.ruby-china.org,发现其服务域名更换了:

    然后删除gem源:

    gem sources --remove https://gems.ruby-china.org/

    修改gem源:

    gem sources -a https://gems.ruby-china.com

    查看gem源是否是最新的:

    gem sources -l

    升级cocoapods:

    sudo gem install -n /usr/local/bin cocoapods --pre

    查看升级后的cocoapods版本:

    pod --version  

    现在最新的是

    MacBook-Pro:get dunkhome$ pod --version 

    1.8.3

  • 相关阅读:
    centos7 安装mysql
    基于flask+requests 个人博客
    python csv、json、pickle数据持久化
    Python之容器、迭代器、生成器
    AJAX常用方法详解
    Python之format详解
    Flask使用MySql数据库
    git 公共服务器
    pci 记录
    检查ept
  • 原文地址:https://www.cnblogs.com/ljcgood66/p/11670814.html
Copyright © 2020-2023  润新知