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 中調試運行時,子線程修改界面會有紫色感嘆號標出,注意修改成回到主線程即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM