zoukankan      html  css  js  c++  java
  • iOS12适配指南

    1.重复文件报错

    build Phases-> 删除多余的info.plist

    2.library not found for -lstdc++

    苹果在XCode10和iOS12中移除了libstdc++这个库,由libc++这个库取而代之,苹果的解释是lib转载自斗玩网stdc++已经标记为废弃有5年了,建议大家使用经过了llvm优化过并且全面支持C++11的libc++库。

    建议把代码调整为依赖 libc++库 如果你引用的第三方厂商提供的sdk中依赖了libstdc++,联系厂商

    3.StatusBar内部结构改变

    现象:crash
      
      crash log:
      
      -[_UIStatusBarIdentifier isEqualToString:]: unrecognized selector sent to instance 0x283452820
      
      * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[_UIStatusBarIdentifier isEqualToString:]: unrecognized selector sent to instance 0x283452820’		
    

    解决方案:

    + (NSString *)getIphoneXNetWorkStates {    
        UIApplication *app = [UIApplication sharedApplication];
        id statusBar = [[app valueForKeyPath:@"statusBar"] valueForKeyPath:@"statusBar"];
        id one = [statusBar valueForKeyPath:@"regions"];
        id two = [one valueForKeyPath:@"trailing"];
        NSArray *three = [two valueForKeyPath:@"displayItems"];
        NSString *state = @"无网络";
        for (UIView *view in three) {
            //alert: iOS12.0 情况下identifier的变成了类"_UIStatusBarIdentifier"而不是NSString,所以会在调用“isEqualToString”方法时发生crash,
            //修改前
    //        NSString *identifier = [view valueForKeyPath:@"identifier"];
            //修改后
            NSString *identifier = [[view valueForKeyPath:@"identifier"] description];
            if ([identifier isEqualToString:@"_UIStatusBarWifiItem.signalStrengthDisplayIdentifier"]) {
                id item = [view valueForKeyPath:@"_item"];
    
                //alert: 这个问题和上边一样itemId是_UIStatusBarIdentifier 类型,不是string
                NSString *itemId = [[item valueForKeyPath:@"identifier"] description];
                if ([itemId isEqualToString:@"_UIStatusBarWifiItem"]) {
                    state = @"WIFI";
                }
                state = @"不确定";
    
            } else if ([identifier isEqualToString:@"_UIStatusBarCellularItem.typeDisplayIdentifier"]) {
                UIView *statusBarStringView = [view valueForKeyPath:@"_view"];
                // 4G/3G/E
                state = [statusBarStringView valueForKeyPath:@"text"];
            }
    
        }
    
        return state;
    }	
    

    4.新版本iPhoneXR,iPhoneXS,iPhoneXS MAX适配

    img

    • 各个机型枚举
    #define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
     
    #define iPhoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
     
    #define iPhoneXS_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)
    
    • 目前iPhonex都是刘海屏,判断处这个特性,就可以统一做适配了

      #define isIPhoneXAll ([UIScreen mainScreen].bounds.size.height == 812 || [UIScreen mainScreen].bounds.size.height == 896)
      
    • 目前iPhonex都是刘海屏,状态栏的高度均为44pt

      #define isIPhoneXAl ([[UIApplication sharedApplication] statusBarFrame].size.height == 44)
      
    • 针对继承自UIScrollView的,需要处理一下内边距 第一步:关闭自动调整内边距

      if (@available(iOS 11.0, *)) {
              [UIScrollView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
      }
      
  • 相关阅读:
    单表通用excle导入(只要是单表都可以,只需要传文件跟表名及用户id即可)
    单表通用excle导出(只要是单表都可以)
    mysql数据库中的mybatis中xml解决in不起作用的问题
    Mysql获取系统时间,年,月,日
    Linux下MySQL的数据库安装
    MP3音频文件的剪切合并方法
    Oracle client客户端简易安装网上文档一
    excel导出功能
    Oracle数据库的创建表全
    Oracle表字段的增加、删除、修改和重命名
  • 原文地址:https://www.cnblogs.com/niit-soft-518/p/10078306.html
Copyright © 2011-2022 走看看