1.Xcode8 运行项目控制台会出现一大堆的 莫名乱码
![](https://i-blog.csdnimg.cn/blog_migrate/b6dfafa1523ad1e9ccf443c55189eee7.webp?x-image-process=image/format,png)
只需要在Xcode ->Product-> Scheme->Edit Scheme中配置OS_ACTIVITY_MODE为disable
![](https://i-blog.csdnimg.cn/blog_migrate/e933558685a8f4b152a5db221bbc7c14.webp?x-image-process=image/format,png)
2. 在iOS10中调用摄像机和相册位置蓝牙等一系列隐私权限的时候,必须要在info.plist文件中配置权限
NSCalendarsUsageDescription
访问日历
NSMicrophoneUsageDescription
访问麦克风
NSAppleMusicUsageDescription
访问媒体数据库
NSMotionUsageDescription
访问运动与健康
NSRemindersUsageDescription
访问提醒事项
NSLocationAlwaysUsageDescription
始终访问位置
NSLocationWhenInUseUsageDescription
使用期间访问位置
NSLocationUsageDescription
访问位置
NSPhotoLibraryUsageDescription
访问相册
NSCameraUsageDescription
访问相机
![](https://i-blog.csdnimg.cn/blog_migrate/4abc049e159ed35a14ef198796acfe86.webp?x-image-process=image/format,png)
3.关于Xcode8没办法使用command+/注释的问题
终端输入:
sudo /usr/libexec/xpccachectl
等运行结束时重启电脑 一定要重启电脑才能用、
4.关于iOS10 的推送 小伙伴们简书上已经有了解决的办法了,挺不错的,这个是链接:http://www.jianshu.com/p/f5337e8f336d
5.iOS10 获取IDFA 的坑
ios10更新之后一旦开启了 设置->隐私->广告->限制广告跟踪之后 获取到的idfa将会是一串00000,而且每次开启在关闭之后 相应的idfa也会重新生成,相当于还原了一次广告标识符。
获取idfa的方法:
#import
NSString *idfa = [[[ASIdentifierManagersharedManager]advertisingIdentifier]UUIDString];
ios10 之后最好加一个判断[[ASIdentifierManagersharedManager]isAdvertisingTrackingEnabled] 返回值是BOOL值 如果返回的YES说明没有 “开启限制广告跟踪”,可以获取到正确的idfa 如果返回的是NO,说明等待你的就是一串00000000000
6.通知问题
iOS7 开始支持后台推送 在iOS9之前,app进入后台后收到通知都会进入该代理方法,获取通知的数据,在iOS10 中,只有后台推送才会进入该方法,即设置推送的content-available才会进入,iOS10 可以使用最新的userNotification.framework或者didReceiveRemoteNotification获取通知内容 不过该方法在iOS10中已经废弃,还是建议适配iOS10
-(void)application:(UIApplication*)applicationdidReceiveRemoteNotification:(NSDictionary*)userInfo
![](https://i-blog.csdnimg.cn/blog_migrate/fe2288e545ba36d1d1ac3cb0ae66bedd.webp?x-image-process=image/format,png)
-(void)application:(UIApplication*)applicationdidReceiveRemoteNotification:(NSDictionary*)userInfofetchCompletionHandler:(void(^)(UIBackgroundFetchResultresult))completionHandlerNS_AVAILABLE_IOS(7_0)__TVOS_PROHIBITED;
7.ATS的问题
iOS 9中默认非HTTS的网络是被禁止的,当然我们也可以把NSAllowsArbitraryLoads设置为YES禁用ATS。不过iOS 10从2017年1月1日起苹果不允许我们通过这个方法跳过ATS,也就是说强制我们用HTTPS,如果不这样的话提交App可能会被拒绝。但是我们可以通过NSExceptionDomains来针对特定的域名开放HTTP可以容易通过审核。
8.iOS 10 UIStatusBar方法过期:
![](https://i-blog.csdnimg.cn/blog_migrate/7602d1c2be80743bcf940a690281d1d2.webp?x-image-process=image/format,png)
在我们开发中有可能用到UIStatusBar一些属性,在iOS 10 中这些方法已经过期了,如果你的项目中有用的话就得需要适配。上面的图片也能发现,如果在iOS 10中你需要使用preferredStatusBar比如这样:
//iOS 10-(UIStatusBarStyle)preferredStatusBarStyle{returnUIStatusBarStyleDefault;}
9.RGB
因为之前我们都是用RGB来设置颜色,反正用起来也不是特别多样化,这次新增的方法应该就是一个弥补吧。所以在iOS 10 苹果官方建议我们使用sRGB,因为它性能更好,色彩更丰富。如果你自己为UIColor写了一套分类的话也可尝试替换为sRGB,UIColor类中新增了两个Api如下:
+(UIColor*)colorWithDisplayP3Red:(CGFloat)displayP3Redgreen:(CGFloat)greenblue:(CGFloat)bluealpha:(CGFloat)alphaNS_AVAILABLE_IOS(10_0);-(UIColor*)initWithDisplayP3Red:(CGFloat)displayP3Redgreen:(CGFloat)greenblue:(CGFloat)bluealpha:(CGFloat)alphaNS_AVAILABLE_IOS(10_0);
10.iOS 10 UITextContentType
// The textContentType property is to provide the keyboard with extra information about the semantic intent of the text document.@property(nonatomic,copy)UITextContentTypetextContentType NS_AVAILABLE_IOS(10_0);// default is nil
在iOS 10UITextField添加了textContentType枚举,指示文本输入区域所期望的语义意义。
使用此属性可以给键盘和系统信息,关于用户输入的内容的预期的语义意义。例如,您可以指定一个文本字段,用户填写收到一封电子邮件确认uitextcontenttypeemailaddress。当您提供有关您期望用户在文本输入区域中输入的内容的信息时,系统可以在某些情况下自动选择适当的键盘,并提高键盘修正和主动与其他文本输入机会的整合。
11.iOS 10 字体随着手机系统字体而改变
当我们手机系统字体改变了之后,那我们App的label也会跟着一起变化,这需要我们写很多代码来进一步处理才能实现,但是iOS 10 提供了这样的属性adjustsFontForContentSizeCategory来设置。因为没有真机,具体实际操作还没去实现,如果理解错误帮忙指正。
UILabel*myLabel=[UILabelnew];/*
UIFont 的preferredFontForTextStyle: 意思是指定一个样式,并让字体大小符合用户设定的字体大小。
*/myLabel.font=[UIFontpreferredFontForTextStyle:UIFontTextStyleHeadline];/*
Indicates whether the corresponding element should automatically update its font when the device’s UIContentSizeCategory is changed.
For this property to take effect, the element’s font must be a font vended using +preferredFontForTextStyle: or +preferredFontForTextStyle:compatibleWithTraitCollection: with a valid UIFontTextStyle.
*///是否更新字体的变化myLabel.adjustsFontForContentSizeCategory=YES;