看各个大神整理而成web
一、检查版本问题算法
不能够像下面这样用api
#define isiOS10 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1]intValue]>=10)
安全
这样能够网络
[[UIDevice currentDevice].systemVersion floatValue] >= 10.0数据结构
二、隐私设置app
你的项目中访问了隐私数据,好比:相机,相册,联系人等,在Xcode8中打开编译的话,通通会crash框架
<!-- 相册 --> <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>
三、UIColor问题dom
官方文档中说:大多数core
开头的图形框架和AVFoundation
都提升了对扩展像素和宽色域色彩空间的支持.经过图形堆栈扩展这种方式比以往支持广色域的显示设备更加容易。如今对UIKit扩展能够在sRGB的色彩空间下工做,性能更好,也能够在更普遍的色域来搭配sRGB颜色.若是你的项目中是经过低级别的api本身实现图形处理的,建议使用sRGB,也就是说在项目中使用了RGB转化颜色的建议转换为使用sRGB,在UIColor
类中新增了两个api:ide
- (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);
四、真色彩显示
真彩色的显示会根据光感应器来自动的调节达到特定环境下显示与性能的平衡效果,若是须要这个功能的话,能够在info.plist
里配置(在Source Code模式下):
<key>UIWhitePointAdaptivityStyle</key>
它有五种取值,分别是:
<string>UIWhitePointAdaptivityStyleStandard</string> // 标准模式 <string>UIWhitePointAdaptivityStyleReading</string> // 阅读模式 <string>UIWhitePointAdaptivityStylePhoto</string> // 图片模式 <string>UIWhitePointAdaptivityStyleVideo</string> // 视频模式 <string>UIWhitePointAdaptivityStyleStandard</string> // 游戏模式
也就是说若是你的项目是阅读类的,就选择UIWhitePointAdaptivityStyleReading
这个模式,五种模式的显示效果是从上往下递减,也就是说若是你的项目是图片处理类的,你选择的是阅读模式,给选择太好的效果会影响性能.
五、ATS问题
---在iOS 9的时候,默认非HTTS的网络是被禁止的,咱们能够在info.plist
文件中添加NSAppTransportSecurity
字典,将NSAllowsArbitraryLoads
设置为YES
来禁用ATS;
---从2017年1月1日起,,全部新提交的 app 默认不容许使用NSAllowsArbitraryLoads
来绕过ATS的限制,默认状况下你的 app 能够访问加密足够强的(TLS V1.2以上)HTTPS内容;
---能够选择使用NSExceptionDomains
设置白名单的方式对特定的域名开放HTTP内容来经过审核,好比说你的应用集成了第三方的登陆分享SDK,能够经过这种方式来作,下面以新浪SDK做为示范(Source Code 模式下):
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>sina.cn</key> <dict> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>weibo.cn</key> <dict> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>weibo. com</key> <dict> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>sinaimg.cn</key> <dict> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>sinajs.cn</key> <dict> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>sina.com.cn</key> <dict> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.0</string> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> </dict> </dict>
---在iOS 10 中info.plist
文件新加入了NSAllowsArbitraryLoadsInWebContent
键,容许任意web页面加载,同时苹果会用 ATS 来保护你的app;
---安全传输再也不支持SSLv3
, 建议尽快停用SHA1
和3DES
算法;
六、UIStatusBar
原来setStatusBarStyle不能用了,如今能够经过属性来设置
@property(nonatomic,readonly)UIStatusBarStyle preferredStatusBarStyle
@property(nonatomic,readonly)BOOL prefersStatusBarHidden
-(BOOL)prefersStatusBarHidden
-(UIStatusBarAnimation)preferredStatusBarUpdateAnimation
七、UITextField
在iOS 10 中,UITextField
新增了textContentType
字段,是UITextContentType
类型,它是一个枚举,做用是能够指定输入框的类型,以便系统能够分析出用户的语义.是电话类型就建议一些电话,是地址类型就建议一些地址.能够在#import <UIKit/UITextInputTraits.h>
文件中,查看textContentType
字段,有如下能够选择的类型:
UITextContentTypeName UITextContentTypeNamePrefix UITextContentTypeGivenName UITextContentTypeMiddleName UITextContentTypeFamilyName UITextContentTypeNameSuffix UITextContentTypeNickname UITextContentTypeJobTitle UITextContentTypeOrganizationName UITextContentTypeLocation UITextContentTypeFullStreetAddress UITextContentTypeStreetAddressLine1 UITextContentTypeStreetAddressLine2 UITextContentTypeAddressCity UITextContentTypeAddressState UITextContentTypeAddressCityAndState UITextContentTypeSublocality UITextContentTypeCountryName UITextContentTypePostalCode UITextContentTypeTelephoneNumber UITextContentTypeEmailAddress UITextContentTypeURL UITextContentTypeCreditCardNumber
八、对UICollectionView进行了优化
对UICollectionView进行了优化,并新增长了预加载的UICollectionViewDataSourcePrefetching代理协议及代理方法
-(void)collectionView: (UICollectionView*)collectionView prefetchItemsAtIndexPaths: (NSArray*)indexPaths
-(void)collectionView: (UICollectionView*)collectionView cancelPrefetchingForItemsAtIndexPaths: (NSArray*)indexPaths
注意:这两个代理方法并不能代替以前读取数据的方法,仅仅是辅助加载数据在iOS 10 以前,UICollectionView上面若是有大量cell,当用户活动很快的时候,整个UICollectionView的卡顿会很明显,为何会形成这样的问题,这里涉及到了iOS 系统的重用机制,当cell准备加载进屏幕的时候,整个cell都已经加载完成,等待在屏幕外面了,也就是整整一行cell都已经加载完毕,这就是形成卡顿的主要缘由,专业术语叫作:掉帧.要想让用户感受不到卡顿,咱们的app必须帧率达到60帧/秒,也就是说每帧16毫秒要刷新一次.
prepareForReuse
方法,在这个方法里面,能够重置cell的状态,加载新的数据;cellForItemAtIndexPath
方法,在这个方法里面给cell赋值模型,而后返回给系统;willDisplayCell
方法,在这个方法里面咱们还能够修改cell,为进入屏幕作最后的准备工做;willDisplayCell
方法后,cell就进去屏幕了.当cell彻底离开屏幕之后,会调用didEndDisplayingCell
方法.prepareForReuse
方法,在这里当cell尚未进去屏幕的时候,就已经提早调用这个方法了,对比以前的区别是以前是cell的上边缘立刻进去屏幕的时候就会调用该方法,而iOS 10 提早到cell还在屏幕外面的时候就调用;cellForItemAtIndexPath
中建立cell,填充数据,刷新状态等操做,相比于以前也提早了;willDisplayCell
方法,原则就是:什么时候须要显示,什么时候再去调用willDisplayCell
方法;didEndDisplayingCell
方法,跟以前同样,cell会进入重用队列.cellForItemAtIndexPath
建立或者生成一个cell.willDisplayCell
方法就能够从新出如今屏幕中了.九、UIRefreshControl
在iOS 10 中, UIRefreshControl能够直接在UICollectionView和UITableView中使用,而且脱离了UITableViewController.如今RefreshControl是UIScrollView的一个属性.
使用方法:
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(loadData) forControlEvents:UIControlEventValueChanged]; collectionView.refreshControl = refreshControl;
十、UserNotifications(用户通知)
iOS 10 中将通知相关的 API 都统一了,在此基础上不少用户定义的通知,而且能够捕捉到各个通知状态的回调.之前通知的概念是:你们想接受的提早作好准备,而后一下全两分发,没收到也无论了,也不关心发送者,如今的用户通知作成了相似于网络请求,先发一个request
获得response
的流程,还封装了error
,能够在各个状态的方法中作一些额外的操做,而且能得到一些字段,好比发送者之类的.这个功能的头文件是:#import <UserNotifications/UserNotifications.h>