iOS 10 更新

1.解决工程中输出无关日志

Edit Scheme -> Run -> Arguments, 在Environment Variables里边添加   OS_ACTIVITY_MODE        disable

 
遗留问题:

还会出现下面这个问题5]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x112b58910) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x112982210). One of the two will be used. Which one is undefined.

 

2.注释快捷键⌘+/失效

重启电脑,如果还不能使用的话就启用命令工具(命令运行 sudo /usr/libexec/xpccachectl),然后重启电脑

 

3.对于插件无法使用

网上推荐的是将Xcode拷贝一份可以使用插件的Xcode(在应用程序中),但是这个Xcode不能打包上传等,建议不要使用这种方法

三方插件解决方法(fix method):让你的Xcode8继续使用插件

 

4.iOS10隐私权限问题

iOS10中调用相机相册等系统功能时,需要在info.plist文件中添加字段,否则会出现闪退的情况

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <!-- 相册 -->   
  2. <key>NSPhotoLibraryUsageDescription</key>   
  3. <string>App需要您的同意,才能访问相册</string>   
  4. <!-- 相机 -->   
  5. <key>NSCameraUsageDescription</key>   
  6. <string>App需要您的同意,才能访问相机</string>   
  7. <!-- 麦克风 -->   
  8. <key>NSMicrophoneUsageDescription</key>   
  9. <string>App需要您的同意,才能访问麦克风</string>   
  10. <!-- 位置 -->   
  11. <key>NSLocationUsageDescription</key>   
  12. <string>App需要您的同意,才能访问位置</string>   
  13. <!-- 在使用期间访问位置 -->   
  14. <key>NSLocationWhenInUseUsageDescription</key>   
  15. <string>App需要您的同意,才能在使用期间访问位置</string>   
  16. <!-- 始终访问位置 -->  
  17. <key>NSLocationAlwaysUsageDescription</key>   
  18. <string>App需要您的同意,才能始终访问位置</string>   
  19. <!-- 日历 -->   
  20. <key>NSCalendarsUsageDescription</key>   
  21. <string>App需要您的同意,才能访问日历</string>   
  22. <!-- 提醒事项 -->   
  23. <key>NSRemindersUsageDescription</key>   
  24. <string>App需要您的同意,才能访问提醒事项</string>   
  25. <!-- 运动与健身 -->   
  26. <key>NSMotionUsageDescription</key<string>App需要您的同意,才能访问运动与健身</string>   
  27. <!-- 健康更新 -->   
  28. <key>NSHealthUpdateUsageDescription</key>   
  29. <string>App需要您的同意,才能访问健康更新 </string>   
  30. <!-- 健康分享 -->   
  31. <key>NSHealthShareUsageDescription</key>   
  32. <string>App需要您的同意,才能访问健康分享</string>   
  33. <!-- 蓝牙 -->   
  34. <key>NSBluetoothPeripheralUsageDescription</key>   
  35. <string>App需要您的同意,才能访问蓝牙</string>   
  36. <!-- 媒体资料库 -->   
  37. <key>NSAppleMusicUsageDescription</key>   
  38. <string>App需要您的同意,才能访问媒体资料库</string>  

iOS10 配置须知


 

5.label中的文字显示不全

Xcode8与Xcode7.3的文字宽度变化(英文字母没有问题,只有汉字有问题)



6.Notification(通知)

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

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

(3)通知不再是简单的文本,现在还可以是图片、视频,自定义通知的展示等等

(4)iOS10相对之前的通知来说更好用更易于管理,并且进行了大规模优化

(5)iOS10之后,本地与远程通知集成在一个方法中

7.ATS问题

iOS10从2017年1月1日起只能使用HTTPS,否则提交App可能会被拒绝。

 

8.iOS10中UICollectionView性能优化

 

9.iOS10 UIColor新增方法

iOS10苹果建议我们使用sRGB,因为它性能更好,色彩更丰富。

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. + (UIColor *)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);  
  2.   
  3. - (UIColor *)initWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);  

10.iOS10 UIScrollView新增refreshControl

也就是说以后只要是继承UIScrollView就支持刷新功能

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. @property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(10_0) __TVOS_PROHIBITED;  
[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. - (void)viewDidLoad {  
  2.     [super viewDidLoad];  
  3.     UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 500)];  
  4.     scrollView.backgroundColor = [UIColor redColor];  
  5.     scrollView.contentSize = CGSizeMake(self.view.bounds.size.width, 1000);  
  6.     [self.view addSubview:scrollView];  
  7.     UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1"]];  
  8.     [scrollView addSubview:imageView];  
  9.     // 添加下拉刷新控件  
  10.     UIRefreshControl *ref = [[UIRefreshControl alloc] init];  
  11.     // 监听刷新方法  
  12.     [ref addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];  
  13.     scrollView.refreshControl = ref;  
  14.     self.view.backgroundColor = [UIColor redColor];  
  15. }  
  16. - (void)refresh:(UIRefreshControl *)ref {  
  17.    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(22 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{  
  18.         // 结束刷新  
  19.         [ref endRefreshing];  
  20.     });  
  21. }  



11.iOS10判断系统版本

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. NSLog(@"%zd %f %@",  
  2.           [[[[UIDevice currentDevice] systemVersion] substringToIndex:1] integerValue],  
  3.           [[UIDevice currentDevice] systemVersion].floatValue,  
  4.           [[UIDevice currentDevice] systemVersion]);  


 
 

12.UIStatusBar的问题

在iOS10中,如果还是用以前设置UIStatusBar类型或者控制隐藏还是显示的方法,会报警告,方法过期,如下图:


要想修改UIStatusBar的样式或者状态使用下图中所示的属性或方法:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. @property(nonatomic, readonly) UIStatusBarStyle preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault  
  2. @property(nonatomic, readonly) BOOL prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to NO  
  3. - (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault  
  4. - (BOOL)prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to NO  
  5. // Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden.  
  6. - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarAnimationFade  

13.UITextField新增字段

在iOS10中,UITextField新增了textContentType字段,是UITextContentType类型,它是一个枚举,作用是可以指定输入框的类型,以便系统可以分析出用户的语义,是电话类型就建议一些电话,是地址类型就建议一些地址。可以在#import<UIkit/UITextInputTraits.h>文件中,查看textContentType字段,有以下可以选择的类型:

 

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. UIKIT_EXTERN UITextContentType const UITextContentTypeName                      NS_AVAILABLE_IOS(10_0);  
  2. UIKIT_EXTERN UITextContentType const UITextContentTypeNamePrefix                NS_AVAILABLE_IOS(10_0);  
  3. UIKIT_EXTERN UITextContentType const UITextContentTypeGivenName                 NS_AVAILABLE_IOS(10_0);  
  4. UIKIT_EXTERN UITextContentType const UITextContentTypeMiddleName                NS_AVAILABLE_IOS(10_0);  
  5. UIKIT_EXTERN UITextContentType const UITextContentTypeFamilyName                NS_AVAILABLE_IOS(10_0);  
  6. UIKIT_EXTERN UITextContentType const UITextContentTypeNameSuffix                NS_AVAILABLE_IOS(10_0);  
  7. UIKIT_EXTERN UITextContentType const UITextContentTypeNickname                  NS_AVAILABLE_IOS(10_0);  
  8. UIKIT_EXTERN UITextContentType const UITextContentTypeJobTitle                  NS_AVAILABLE_IOS(10_0);  
  9. UIKIT_EXTERN UITextContentType const UITextContentTypeOrganizationName          NS_AVAILABLE_IOS(10_0);  
  10. UIKIT_EXTERN UITextContentType const UITextContentTypeLocation                  NS_AVAILABLE_IOS(10_0);  
  11. UIKIT_EXTERN UITextContentType const UITextContentTypeFullStreetAddress         NS_AVAILABLE_IOS(10_0);  
  12. UIKIT_EXTERN UITextContentType const UITextContentTypeStreetAddressLine1        NS_AVAILABLE_IOS(10_0);  
  13. UIKIT_EXTERN UITextContentType const UITextContentTypeStreetAddressLine2        NS_AVAILABLE_IOS(10_0);  
  14. UIKIT_EXTERN UITextContentType const UITextContentTypeAddressCity               NS_AVAILABLE_IOS(10_0);  
  15. UIKIT_EXTERN UITextContentType const UITextContentTypeAddressState              NS_AVAILABLE_IOS(10_0);  
  16. UIKIT_EXTERN UITextContentType const UITextContentTypeAddressCityAndState       NS_AVAILABLE_IOS(10_0);  
  17. UIKIT_EXTERN UITextContentType const UITextContentTypeSublocality               NS_AVAILABLE_IOS(10_0);  
  18. UIKIT_EXTERN UITextContentType const UITextContentTypeCountryName               NS_AVAILABLE_IOS(10_0);  
  19. UIKIT_EXTERN UITextContentType const UITextContentTypePostalCode                NS_AVAILABLE_IOS(10_0);  
  20. UIKIT_EXTERN UITextContentType const UITextContentTypeTelephoneNumber           NS_AVAILABLE_IOS(10_0);  
  21. UIKIT_EXTERN UITextContentType const UITextContentTypeEmailAddress              NS_AVAILABLE_IOS(10_0);  
  22. UIKIT_EXTERN UITextContentType const UITextContentTypeURL                       NS_AVAILABLE_IOS(10_0);  
  23. UIKIT_EXTERN UITextContentType const UITextContentTypeCreditCardNumber          NS_AVAILABLE_IOS(10_0);  

14.推送

所有的推送平台,不管是极光还是什么的,要想收到推送,这个必须打开



 

15.蓝牙相关

CBCentralManagerState废弃,使用CBManagerState替代

CBCentralManager直接继承于CBManager,里面直接声明的属性:

@property(nonatomic, assign, readonly) CBManagerState state;

16.openURL的方法被遗弃,使用其替换方法

openURL:options:completionHandler:

17.iOS10字体随着手机系统字体而改变

iOS 10提供了这样的属性adjustsFontForContentSizeCategory来设置

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. UILabel *myLabel = [UILabel new];  
  2. // UIFont 的preferredFontForTextStyle:意思是指定一个样式,并让字体大小符合用户设定的字体大小  
  3. myLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];  
  4. myLabel.adjustsFontForContentSizeCategory = YES;    // 是否更新字体的变化  
原文地址:https://www.cnblogs.com/yecong/p/6104452.html