兼容iOS 10 ,升级xcode8出的一堆问题的解决方案,以及一些适配.

本文介绍iOS10及Xcode8的重要变化,包括推送通知改进、字体适配调整、Xcode8的注释快捷键修复、颜色管理更新、版本判断技巧、HTTPS政策变化、隐私权限设置等。

转自:http://blog.youkuaiyun.com/gbking/article/details/52587149


1、推送 

xcode 升级到8之后很多人的推送接收不到了.获取不到token了 一朋友搞了一小时没找到原因. 只因看下图吧....我发觉xcode 我不打开他也能收到通知. 但是到了8(必须打开了才能收到推送) . 貌似不行了    大家对号入座吧.

下面普及下ios10跟之前的推送的区别

  • iOS 9 以前的通知

     

    1.在调用方法时,有些方法让人很难区分,容易写错方法,这让开发者有时候很苦恼。

    2.应用在运行时和非运行时捕获通知的路径还不一致。

    3.应用在前台时,是无法直接显示远程通知,还需要进一步处理。

    4.已经发出的通知是不能更新的,内容发出时是不能改变的,并且只有简单文本展示方式,扩展性根本不是很好。

  • iOS 10 开始的通知 

    1.所有相关通知被统一到了UserNotifications.framework框架中。

    2.增加了撤销、更新、中途还可以修改通知的内容。

    3.通知不在是简单的文本了,可以加入视频、图片,自定义通知的展示等等。

    4.iOS 10相对之前的通知来说更加好用易于管理,并且进行了大规模优化,对于开发者来说是一件好事。

    5.iOS 10开始对于权限问题进行了优化,申请权限就比较简单了(本地与远程通知集成在一个方法中)。

 

 

2、字体适配的问题

ios 9 之前的lab 字体可以显示全,但是到了ios10 发觉字体显示不全了.得适配啊.app 会跟随手机系统字体大小而改变了.

简单粗暴地方法就是不让他跟着手机系统的字体改变而改变.

label.adjustsFontForContentSizeCategory = YES;

 

3、xcode 8运行打印一堆没用的东西Xcode 8的问题,解决办法是设置OS_ACTIVITY_MODE : disable如下图:

 

 

4、xcode8的注释快捷键是什么,   command+/ 不行了

解决办法:

因为苹果解决xcode ghost。把插件屏蔽了。解决方法
命令运行: sudo /usr/libexec/xpccachectl 
然后必须重启电脑后生效

5 、颜色问题, iOS 10 苹果官方建议我们使用sRGB,因为它性能更好,色彩更丰富。

UIColor类中新增了两个Api如下: 

+ (UIColor *)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0); - (UIColor *)initWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);

 

 

6 判断版本问题 

建议用   [[UIDevice currentDevice] systemVersion]

Swift

if #available(iOS 10.0, *) {

           // iOS 10.0啊            

print("iOS 10.0");        

} else

{

}

;

 

7、https的问题

iOS 9中默认非HTTS的网络是被禁止的,当然我们也可以把NSAllowsArbitraryLoads设置为YES禁用ATS。不过iOS 10从2017年1月1日起苹果不允许我们通过这个方法跳过ATS,也就是说强制我们用HTTPS,如果不这样的话提交App可能会被拒绝。但是我们可以通过NSExceptionDomains来针对特定的域名开放HTTP可以容易通过审核。

 

8、隐私权限 

iOS 10 开始对隐私权限更加严格,如果你不设置就会直接崩溃,现在很多遇到崩溃问题了,一般解决办法都是在info.plist文件添加对应的Key-Value就可以了。

<code class="xml" style="margin: 0px; padding: 0px;"><span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 相册 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSPhotoLibraryUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问相册<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 相机 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSCameraUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问相机<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 麦克风 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSMicrophoneUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问麦克风<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 位置 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSLocationUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问位置<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 在使用期间访问位置 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSLocationWhenInUseUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能在使用期间访问位置<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 始终访问位置 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSLocationAlwaysUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能始终访问位置<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 日历 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSCalendarsUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问日历<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 提醒事项 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSRemindersUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问提醒事项<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 运动与健身 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSMotionUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> <span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问运动与健身<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 健康更新 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSHealthUpdateUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问健康更新 <span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 健康分享 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSHealthShareUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问健康分享<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 蓝牙 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSBluetoothPeripheralUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问蓝牙<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string> 
<span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.8;"><!-- 媒体资料库 --> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key>NSAppleMusicUsageDescription<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">key> 
<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"><<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string>App需要您的同意,才能访问媒体资料库<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.8;"></<span class="hljs-title" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.8;">string></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code><br style="margin: 0px; padding: 0px;" /><br style="margin: 0px; padding: 0px;" />或者


该数据集通过合成方式模拟了多种发动机在运行过程中的传感器监测数据,旨在构建一个用于机械系统故障检测的基准资源,特别适用于汽车领域的诊断分析。数据按固定时间间隔采集,涵盖了发动机性能指标、异常状态以及工作模式等多维度信息。 时间戳:数据类型为日期时间,记录了每个数据点的采集时刻。序列起始于2024年12月24日10:00,并以5分钟为间隔持续生成,体现了对发动机运行状态的连续监测。 温度(摄氏度):以浮点数形式记录发动机的温度读数。其数值范围通常处于60至120摄氏度之间,反映了发动机在常规工况下的典型温度区间。 转速(转/分钟):以浮点数表示发动机曲轴的旋转速度。该参数在1000至4000转/分钟的范围内随机生成,符合多数发动机在正常运转时的转速特征。 燃油效率(公里/升):浮点型变量,用于衡量发动机的燃料利用效能,即每升燃料所能支持的行驶里程。其取值范围设定在15至30公里/升之间。 振动_X、振动_Y、振动_Z:这三个浮点数列分别记录了发动机在三维空间坐标系中各轴向的振动强度。测量值标准化至0到1的标度,较高的数值通常暗示存在异常振动,可能与潜在的机械故障相关。 扭矩(牛·米):以浮点数表征发动机输的旋转力矩,数值区间为50至200牛·米,体现了发动机的负载能力。 功率输(千瓦):浮点型变量,描述发动机单位时间内做功的速率,取值范围为20至100千瓦。 故障状态:整型分类变量,用于标识发动机的异常程度,共分为四个等级:0代表正常状态,1表示轻微故障,2对应中等故障,3指示严重故障。该列作为分类任务的目标变量,支持基于传感器数据预测故障等级。 运行模式:字符串类型变量,描述发动机当前的工作状态,主要包括:怠速(发动机运转但无负载)、巡航(发动机在常规负载下平稳运行)、重载(发动机承受高负荷或高压工况)。 数据集整体包含1000条记录,每条记录对应特定时刻的发动机性能快照。其中故障状态涵盖从正常到严重故障的四级分类,有助于训练模型实现故障预测与诊断。所有数据均为合成生成,旨在模拟真实的发动机性能变化与典型故障场景,所包含的温度、转速、燃油效率、振动、扭矩及功率输等关键传感指标,均为影响发动机故障判定的重要因素。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值