iOS 11とXcode 9の試用後の一部の問題のまとめ

3032 ワード

  • tableView:heightForFooterInSection:無効な設定
  • iOS 11以前は、以下の設定に問題はありませんでしたが、最近ではXcode 9を使用してiOS 11に適合する際に、以下のコードが無効であることがわかりました.
    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
        if (section == 0) {
            return 0.001;
        }
        return 30;
    }
    

    修正方法は次のとおりです.
  • メソッド1 viewDidLoadに次のコード
  • を追加する
    if (@available(iOS 11.0, *)) {
          self.tableView.estimatedRowHeight = 0;
          self.tableView.estimatedSectionHeaderHeight = 0;
          self.tableView.estimatedSectionFooterHeight = 0;
    }
    
  • メソッド2 UITableViewDelegateのtableView:viewForFooterInSectionを実装する方法
  • #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
            return nil;
    }
    #endif
    

    はい、nilを返しても高さ設定が有効になります.
  • カスタムUInavigationBarおよびUItoolBar座標問題
  • この問題は必然的で、結局アップルはそれらを修正して、ここで私はさっき出会った問題だけを話します.ここでは1万行のコードを省略し,説明のみを用いる.
    // UIToolbar,  rectButton、circleButton    buttonClick:  
    UIToolbar *markToolBar = [[UIToolbar alloc] initWithFrame:CGRectZero];    
    UIBarButtonItem *rectItem = [[UIBarButtonItem alloc] initWithCustomView:self.rectButton];
    UIBarButtonItem *circleItem = [[UIBarButtonItem alloc] initWithCustomView:self.circleButton];   
    
    UIBarButtonItem *flexibleitem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemFlexibleSpace) target:self action:nil];
    
    NSArray *items = @[rectItem,flexibleitem,circleItem];
    [markToolBar setItems:items animated:YES];
    

    ここでbuttonをクリックするとbuttonの座標iOS 11を得る必要があります.
    -(void)buttonClick:(UIButton *)sender { CGRect viewFrame = sender.frame; }
    Xcode 9を使用するiOS 11のシミュレータでは、このようにして得られる座標は(0,0,30,30)である.問題が発見されたでしょう、CGPointは(0,0)である.これは間違っている.仕方なく、このように変えて、生きているうちに使うしかありません.
    -(void)buttonClick:(UIButton *)sender { CGRect viewFrame = [sender convertRect:sender.bounds toView:self]; }
  • はXcode 8を用いる.xとXcode 9の複数回のコンパイルコードは実機がコンパイルできるが、シミュレータのコンパイルが通らない場合がある
  • .
    キーワード:Xcode、ネイティブコンパイル通過、シミュレータコンパイル失敗
    まず,コードは問題なく,以前に使用した場合,実機でもシミュレータでも正常に使用されていた.これにより、あるライブラリがシミュレータをサポートしていない場合を排除します.シミュレータを使用してコンパイルすると、ヒントの問題は
    lexical or preprocessor issue“xxx.h”file not foundはこれらのエラープロンプトに似ています.
    毎回の再起動シミュレータを経て、Xcodeを再起動して、パソコンを再起動して、脳を再起動して、再起動して......最後の解決策は、ローカルコンピュータでシミュレータキャッシュファイルを消去することです.
  • UITableViewとUIcollectionViewはiOS 11
  • に最適です.
    キーワード:UITableView、UIcollectionView Appdelegate.mのdidFinishLaunchingWithOptions:メソッドに次のコードを追加すると、iOS 11のUItableViewとUIcollectionViewをグローバルに適合させることができます.
        if (@available(ios 11.0,*)) {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        UITableView.appearance.estimatedRowHeight = 0;
        UITableView.appearance.estimatedSectionFooterHeight = 0;
        UITableView.appearance.estimatedSectionHeaderHeight = 0;
        }
    

    iOSの更新のたびに、硝煙のない戦争が行われています.しかし、私はこの戦争が好きです.私も参加者だからです.何?また似合う?!はい、少々お待ちください.このお茶を飲みました.