iOS10 App适配权限 Push Notifications 字体Frame 遇到的坑!!!!

添加配置权限html

    <!-- 相册 -->
    <key>NSPhotoLibraryUsageDescription</key>
    <string>"xx"想使用您的相册,须要您的容许</string>
    <!-- 相机 -->
    <key>NSCameraUsageDescription</key>
    <string>"xx"想使用您的相机,须要您的容许</string>
    <!-- 麦克风 -->
    <key>NSMicrophoneUsageDescription</key>
    <string>"xx"想使用您的麦克风,须要您的容许</string>
    <!-- 位置 -->
    <key>NSLocationUsageDescription</key>
    <string>"xx"想访问您的位置,请您容许</string>
    <!-- 日历 -->
    <key>NSCalendarsUsageDescription</key>
    <string>"xx"想访问您的日历,请您容许</string>
    <!-- 媒体资料库 -->
    <key>NSAppleMusicUsageDescription</key>
    <string>"xx"想访问您的媒体资料库,请您容许</string>
    <!-- 蓝牙 -->
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>"xx"想访问您的蓝牙,请您容许</string>
    <!--通信录 -->
    <key>NSContactsUsageDescription</key>
    <string>"xx"想访问您的通信录,请您容许</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>请点击“容许”。若不容许,您将没法正常使用“附近”的功能。</string>

添加Push Notifications支持ios

 

开关开启后会自动生成xxxx.entitlements文件app

这里须要注意几点字体

    生成的该文件是否包含到你的打包工程中Bundle Resources中 若是没有手动添加进去spa

 

 若是工程有多个Target 且多个证书在一块儿建议不要使用 Automatically manage signing3d

采用下面的这种方法code

 

总结htm

 第一个 咱们的项目是多个app时的因此在配置证书的时候要指定对应的证书,自动适配会适配不许确,由于咱们的多个工程分多个target好多共用的工程。blog

 第二个 就是生成的entitlements文件要包含到bundle中ip

 

适配字体

ios中适配sb中的文本... 最好的办法就是手动变动frame

纯代码的页面能够在计算字体size的时候根据比例添加一些frame

+(CGSize)textFrameWithString:(NSString *)text width:(float)width fontSize:(NSInteger)fontSize
{
    NSDictionary *dict = @{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]};
    // 根据第一个参数的文本内容,使用280*float最大值的大小,使用系统14号字,返回一个真实的frame size : (280*xxx)!!
    CGRect frame = [text boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil];
    CGSize textSize = frame.size;
    CGFloat scale = 17.5/17.0;
    
    // iOS 10
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
        textSize.width = textSize.width * scale;
        textSize.height = textSize.height * scale;
    }
    return textSize;
}

 

iOS10好多坑 你们慢慢趟过去。