iOS 13に適した穴

3032 ワード

アップルプライベートAPIの使用
  • UISearchBarの取得_searchFieldオブジェクト
  • //iOS 13  :
    UITextField *searchField = [searchBar valueForKey:@"_searchField"];// iOS 13     Crash
    
    //iOS  13      :
    UITextField *searchField;
    //     searchTextField    13.0     ,      iOS  ,       
    if(@available(iOS 13.0, *)){
      searchField = searchBar.searchTextField;
    }else{
      searchField = [searchBar valueForKey:@"_searchField"];
    }
    
  • UItextFieldのplaceholderのcolor属性を変更する
  • //iOS 13  :
    [textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    
    //iOS  13      :
    NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName:[UIColor grayColor]}];
    textField.attributedPlaceholder = placeholderString;
    

    UItabBar切替後文字色異常
    解決策:
    //     unselectedItemTintColor    10.0     ,      iOS  ,       
    if(@available(iOS 10.0, *)){
         [[UITabBar appearance] setUnselectedItemTintColor:[UIColor grayColor]];
    }
    

    モードインタラクション
    presentViewControllerを使用してジャンプすると、デフォルトはフルスクリーンではなく、ドロップダウンして前のページに戻ると偶発的なCrashがあります.ここでmodalPresentationsStyleプロパティを変更する必要があります.
    VC2.modalPresentationStyle = UIModalPresentationFullScreen;
    [VC1 presentViewController:VC2 animated:YES completion:nil];
    

    ダークモード
    iOS 13のいくつかのセールスポイントの1つですが、適切に組み合わせるには非常に面倒で、開発の作業量は少なくありません.2つの解決策があります.
  • infoを配置する.plistのUserInterfaceStyleはライトで、暴力的に解決した.
  • 老实适配,在所有需要设置色的地方逐一判断,并且应对xcassets素材也要修正.

  • BluetoothプライバシーPrivacyのKeyが変わりました
    AppがBluetoothハードウェアデバイスに接続する必要がある場合はinfoを構成する必要があることはよく知られています.plistのN s B u e t o o o t h P e r i p heralUsageDescription:
    Privacy - Bluetooth Peripheral Usage Description
    

    iOS 13以降、つまりあなたのXcode上のDeployment Targetが13.0+の場合、NSBluetoothAlwaysUsageDescriptionに置き換える必要があります
    Privacy - Bluetooth Always Usage Description
    

    交換しないと、コンストラクションApp Store Connectコンストラクションバージョンをコミットする処理フェーズで戻され、レビューをコミットできません--!
    ナビゲーションバーUIBarButtonItemボタン位置ずれの問題
    Gitを参照:https://github.com/spicyShrimp/UINavigation-SXFixSpacesx_を変更できます.defaultFixSpaceプロパティを使用して、ナビゲーションバーボタンを設定する必要がある場所で、ボタンのオフセット距離を設定します.
    //    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:action title:@"  "];;
    //    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:action image:[UIImage imageNamed:@"  "]];
    

    LaunchImage廃棄
    Project->Launch Screen File構成では、以前はAssetsを指定できました.xcassetsのLaunchImageを起動画像としてXcode 11+にアップグレードすると、LaunchScreenがデフォルトで指定されます.storyboardは起動ページとして、上記のパラメータの変更は無効です
    keyWindowのAPIの取得
    UIWindow *window = [[UIApplication sharedApplication].keyWindow];//iOS 13  
    UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];//iOS 13  keywindow   
    

    その他の問題は改善しなければならない...
    もし本文があなたに役に立つなら、いいねを覚えています.