Ios10各种坑

今天更新Xcode8遇到了各种问题。

  • 如果你是老版本请不要使用swift最近版.则是选择2.3版本


  • 注释快捷键不能使用

    • 命令后 输入 sudo /usr/libexec/xpccachectl
    • 记得一定要重启机子后才有用
  • 代理方式也需要更改

    • 例如原来是xxx.delegate = self ;
    • 现在需要修改成xxx.delegate = (id<CAAnimationDelegate>)self;
  • 推送都需要重新配置

#######define isiOS10 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=10)
这句话截取一位,ios10截取下来就是1.所以永远会返回no.

#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
  • 访问相册等隐私会闪退
    • 要想解决这个问题,只需要在info.plist添加
    • NSContactsUsageDescription的
    • key, value自己随意填写就可以,这里列举出对应的key
<!-- 相册 --> <key>NSPhotoLibraryUsageDescription</key> <string>App需要您的同意,才能访问相册</string> 
<!-- 相机 --> <key>NSCameraUsageDescription</key> <string>App需要您的同意,才能访问相机</string> 
<!-- 麦克风 --> <key>NSMicrophoneUsageDescription</key> <string>App需要您的同意,才能访问麦克风</string> 
<!-- 位置 --> <key>NSLocationUsageDescription</key> <string>App需要您的同意,才能访问位置</string>
 <!-- 在使用期间访问位置 --> <key>NSLocationWhenInUseUsageDescription</key> <string>App需要您的同意,才能在使用期间访问位置</string>
 <!-- 始终访问位置 --> <key>NSLocationAlwaysUsageDescription</key> <string>App需要您的同意,才能始终访问位置</string>
 <!-- 日历 --> <key>NSCalendarsUsageDescription</key> <string>App需要您的同意,才能访问日历</string> 
<!-- 提醒事项 --> <key>NSRemindersUsageDescription</key> <string>App需要您的同意,才能访问提醒事项</string>
 <!-- 运动与健身 --> <key>NSMotionUsageDescription</key> <string>App需要您的同意,才能访问运动与健身</string>
 <!-- 健康更新 --> <key>NSHealthUpdateUsageDescription</key> <string>App需要您的同意,才能访问健康更新 </string> 
<!-- 健康分享 --> <key>NSHealthShareUsageDescription</key> <string>App需要您的同意,才能访问健康分享</string> 
<!-- 蓝牙 --> <key>NSBluetoothPeripheralUsageDescription</key> <string>App需要您的同意,才能访问蓝牙</string> 
<!-- 媒体资料库 --> <key>NSAppleMusicUsageDescription</key> <string>App需要您的同意,才能访问媒体资料库</string>

Xcode里选中 ->target ->Capabilities ->Background Modes.选择对应权限.

  • SiriKit
    在 iOS 10 中,我们只能用 SiriKit 来做六类事情,分别是:

  • 语音和视频通话

  • 发送消息

  • 发送或接收付款

  • 搜索照片

  • 约车

  • 管理健身
    具体请看官方文档

  • 通知
    iOS 10 又新增了为通知添加音频 图片 甚至视频的功能 现在 你的通知不仅仅是提醒用户回到应用的入口 更成为了一个展示应用内容 向用户传递多媒体信息的窗口 也新增很多关于通知的api 现在基本与网络请求一样发送一个请求 然后得到服务器所返回的数据这类的

#import <UserNotifications/NSString+UserNotifications.h>
#import <UserNotifications/UNError.h>
#import <UserNotifications/UNNotification.h>
#import <UserNotifications/UNNotificationAction.h>
#import <UserNotifications/UNNotificationAttachment.h>
#import <UserNotifications/UNNotificationCategory.h>
#import <UserNotifications/UNNotificationContent.h>
#import <UserNotifications/UNNotificationRequest.h>
#import <UserNotifications/UNNotificationResponse.h>
#import <UserNotifications/UNNotificationSettings.h>
#import <UserNotifications/UNNotificationSound.h>
#import <UserNotifications/UNNotificationTrigger.h>
#import <UserNotifications/UNUserNotificationCenter.h>
#import <UserNotifications/UNNotificationServiceExtension.h>
  • UIColor增加了两个新的api
  • rgb转换颜色 建议用下面两个方法
- (UIColor *)initWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);
+ (UIColor *)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容