用Xcode8打开工程后,比较明显的就是下图了,这个是苹果的新特性,能够帮助咱们自动管理证书。建议你们勾选这个Automatically manage signing(Ps.可是在beat2版本我用的时候,彻底不能够,GM版本居然神奇的又好了。)php
下面我来讲说可能会出现的问题:css
1.Xcode未设置开发者帐号状况下的截图git
解决办法是:你们在Xcode的偏好设置中,添加苹果帐号,便可。github
2.设备机器未添加进开发者的Device状况下的截图web
解决办法是:你们在官网将设备添加进开发机后,陪下描述文件从新下个描述文件便可。sql
3.正常状况:Xcode配置登陆开发者帐号后的图片,耐心等待便可。数组
等待完成以后的图xcode
使用Xcode8打开xib文件后,会出现下图的提示。性能优化
你们选择Choose Device便可。
以后你们会发现布局啊,frame乱了,只须要更新一下frame便可。以下图网络
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
这句话,以及把< document >中的toolsVersion和< plugIn >中的version改为你正常的xib文件中的值使用Xcode8以后,有些代码可能就编译不过去了,具体我就说说我碰到的问题。
1.UIWebView的代理方法:
**注意要删除NSError前面的 nullable,不然报错。
- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error { [self hideHud]; }
这个是由于苹果解决xcode ghost,把插件屏蔽了。
解决方法
打开终端,命令运行: sudo /usr/libexec/xpccachectl
而后必须重启电脑后生效
注意:Xcode8内置了开启注释的功能,位置在这里
快捷键的设置在这里
貌似Xcode8取消了三方插件的功能,具体能够查阅下Xcode8 Source Editor
注意,添加的时候,末尾不要有空格
咱们须要打开info.plist文件添加相应权限的说明,不然程序在iOS10上会出现崩溃。
具体以下图:
麦克风权限:Privacy - Microphone Usage Description 是否容许此App使用你的麦克风?
相机权限: Privacy - Camera Usage Description 是否容许此App使用你的相机?
相册权限: Privacy - Photo Library Usage Description 是否容许此App访问你的媒体资料库?通信录权限: Privacy - Contacts Usage Description 是否容许此App访问你的通信录?
蓝牙权限:Privacy - Bluetooth Peripheral Usage Description 是否许允此App使用蓝牙?
语音转文字权限:Privacy - Speech Recognition Usage Description 是否容许此App使用语音识别?
日历权限:Privacy - Calendars Usage Description 是否容许此App使用日历?
定位权限:Privacy - Location When In Use Usage Description 咱们须要经过您的地理位置信息获取您周边的相关数据
定位权限: Privacy - Location Always Usage Description 咱们须要经过您的地理位置信息获取您周边的相关数据
定位的须要这么写,防止上架被拒。
经有的朋友提醒,发现程序内原来2个字的宽度是24,如今2个字须要27的宽度来显示了。。
但愿有解决办法的朋友,评论告我一下耶,谢谢啦
以下图的部分,不要忘记打开。全部的推送平台,无论是极光仍是什么的,要想收到推送,这个是必须打开的哟✌️
以后就应该能够收到推送了。另外,极光推送也推出新版本了,你们也能够更新下。
PS.苹果此次对推送作了很大的变化,但愿你们多查阅查阅,处理推送的代理方法也变化了。
// 推送的代理 [<UNUserNotificationCenterDelegate>]
iOS10收到通知再也不是在[application: didReceiveRemoteNotification:]
方法去处理, iOS10推出新的代理方法,接收和处理各种通知(本地或者远程)
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { //应用在前台收到通知 NSLog(@"========%@", notification);}- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { //点击通知进入应用 NSLog(@"response:%@", response);}
稍后我会更新文章,对推送作一个详细的讲解。
更新Xcode8以后,新创建工程,都会打印一堆莫名其妙看不懂的Log.
如这些
subsystem: com.apple.UIKit, category: HIDEventFiltered, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1,
屏蔽的方法以下:
Xcode8里边 Edit Scheme-> Run -> Arguments, 在Environment Variables里边添加
OS_ACTIVITY_MODE = Disable
若是写了以后仍是打印log,请从新勾选对勾,就能够解决了
Xcode 8 uses library validation. It won't load in-process plugins anymore.
这个是因为苹果已经重置插件这块,但有部分优秀的插件已经内置在Xcode了,总体来讲,对我影响并非那么大。
本身尚未尝试过, 由于听说不是持久的解决方案,有须要和兴趣再尝试吧! 另外若是使用 MakeXcodeGr8Again 注意参考下这篇文章:如何让 Xcode8 继续支持 Plugin。
filter
and空白日志页
从新显示出来。
iOS 9中默认非HTTS的网络是被禁止的,固然咱们也能够把NSAllowsArbitraryLoads
设置为YES
禁用ATS
。不过iOS 10从2017年1月1日起苹果不容许咱们经过这个方法跳过ATS
,也就是说强制咱们用HTTPS
,若是不这样的话提交App可能会被拒绝。可是咱们能够经过NSExceptionDomains
来针对特定的域名开放HTTP
能够容易经过审核。
NSExceptionDomains方式 设置域。能够简单理解成,把不支持https协议的接口设置成http的接口。
具体方法:
1)、在项目的info.plist中添加一个Key:App Transport Security Settings,类型为字典类型。
2)、而后给它添加一个Exception Domains,类型为字典类型;
3)、把须要的支持的域添加給Exception Domains。其中域做为Key,类型为字典类型。
4)、每一个域下面须要设置3个属性:NSIncludesSubdomains、NSExceptionRequiresForwardSecrecy、NSExceptionAllowsInsecureHTTPLoads。
如图:
在咱们开发中有可能用到UIStatusBar
一些属性,在iOS 10 中这些方法已通过期了,若是你的项目中有用的话就得须要适配。
上面的图片也能发现,若是在iOS 10中你须要使用preferredStatusBar
好比这样:
//iOS 10 - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; }
随着开发者对UICollectionView
的信赖,项目中用的地方也比较多,可是仍是存在一些问题,好比有时会卡顿、加载慢等。因此iOS 10 对UICollectionView
进一步的优化。
在iOS 10 以前,UICollectionView上面若是有大量cell,当用户活动很快的时候,整个UICollectionView的卡顿会很明显,为何会形成这样的问题,这里涉及到了iOS 系统的重用机制,当cell准备加载进屏幕的时候,整个cell都已经加载完成,等待在屏幕外面了,也就是整整一行cell都已经加载完毕,这就是形成卡顿的主要缘由,专业术语叫作:掉帧.
要想让用户感受不到卡顿,咱们的app必须帧率达到60帧/秒,也就是说每帧16毫秒要刷新一次.
iOS 10 以前UICollectionViewCell的生命周期是这样的:
prepareForReuse
方法,在这个方法里面,能够重置cell的状态,加载新的数据;cellForItemAtIndexPath
方法,在这个方法里面给cell赋值模型,而后返回给系统;willDisplayCell
方法,在这个方法里面咱们还能够修改cell,为进入屏幕作最后的准备工做;willDisplayCell
方法后,cell就进去屏幕了.当cell彻底离开屏幕之后,会调用didEndDisplayingCell
方法.iOS 10 UICollectionViewCell的生命周期是这样的:
prepareForReuse
方法,在这里当cell尚未进去屏幕的时候,就已经提早调用这个方法了,对比以前的区别是以前是cell的上边缘立刻进去屏幕的时候就会调用该方法,而iOS 10 提早到cell还在屏幕外面的时候就调用;cellForItemAtIndexPath
中建立cell,填充数据,刷新状态等操做,相比于以前也提早了;willDisplayCell
方法,原则就是:什么时候须要显示,什么时候再去调用willDisplayCell
方法;didEndDisplayingCell
方法,跟以前同样,cell会进入重用队列.cellForItemAtIndexPath
建立或者生成一个cell.willDisplayCell
方法就能够从新出如今屏幕中了.iOS 10 新增长的Pre-Fetching预加载
这个是为了下降UICollectionViewCell在加载的时候所花费的时间,在 iOS 10 中,除了数据源协议和代理协议外,新增长了一个UICollectionViewDataSourcePrefetching
协议,这个协议里面定义了两个方法: - (void)collectionView:(UICollectionView *)collectionView prefetchItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_AVAILABLE_IOS(10_0); - (void)collectionView:(UICollectionView *)collectionView cancelPrefetchingForItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_AVAILABLE_IOS(10_0);
在ColletionView prefetchItemsAt indexPaths
这个方法是异步预加载数据的,当中的indexPaths
数组是有序的,就是item接收数据的顺序; CollectionView cancelPrefetcingForItemsAt indexPaths
这个方法是可选的,能够用来处理在滑动中取消或者下降提早加载数据的优先级.
注意:这个协议并不能代替以前读取数据的方法,仅仅是辅助加载数据.
Pre-Fetching预加载对UITableViewCell一样适用.
如下是官方文档的说明:
Most graphics frameworks throughout the system, including Core Graphics, Core Image, Metal, and AVFoundation, have substantially improved support for extended-range pixel formats and wide-gamut color spaces. By extending this behavior throughout the entire graphics stack, it is easier than ever to support devices with a wide color display. In addition, UIKit standardizes on working in a new extended sRGB color space, making it easy to mix sRGB colors with colors in other, wider color gamuts without a significant performance penalty.
Here are some best practices to adopt as you start working with Wide Color.
In iOS 10, the UIColor class uses the extended sRGB color space and its initializers no longer clamp raw component values to between 0.0 and 1.0. If your app relies on UIKit to clamp component values (whether you’re creating a color or asking a color for its component values), you need to change your app’s behavior when you link against iOS 10.
When performing custom drawing in a UIView on an iPad Pro (9.7 inch), the underlying drawing environment is configured with an extended sRGB color space.
If your app renders custom image objects, use the new UIGraphicsImageRenderer class to control whether the destination bitmap is created using an extended-range or standard-range format.
If you are performing your own image processing on wide-gamut devices using a lower level API, such as Core Graphics or Metal, you should use an extended range color space and a pixel format that supports 16-bit floating-point component values. When clamping of color values is necessary, you should do so explicitly.
Core Graphics, Core Image, and Metal Performance Shaders provide new options for easily converting colors and images between color spaces.
由于以前咱们都是用RGB
来设置颜色,反正用起来也不是特别多样化,此次新增的方法应该就是一个弥补吧。因此在iOS 10 苹果官方建议咱们使用sRGB
,由于它性能更好,色彩更丰富。若是你本身为UIColor
写了一套分类的话也可尝试替换为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);
// The textContentType property is to provide the keyboard with extra information about the semantic intent of the text document.@property(nonatomic,copy) UITextContentType textContentType NS_AVAILABLE_IOS(10_0); // default is nil
在iOS 10 UITextField
添加了textContentType
枚举,指示文本输入区域所指望的语义意义。
使用此属性能够给键盘和系统信息,关于用户输入的内容的预期的语义意义。例如,您能够指定一个文本字段,用户填写收到一封电子邮件确认uitextcontenttypeemailaddress
。当您提供有关您指望用户在文本输入区域中输入的内容的信息时,系统能够在某些状况下自动选择适当的键盘,并提升键盘修正和主动与其余文本输入机会的整合。
当咱们手机系统字体改变了以后,那咱们App
的label
也会跟着一块儿变化,这须要咱们写不少代码来进一步处理才能实现,可是iOS 10 提供了这样的属性adjustsFontForContentSizeCategory
来设置。由于没有真机,具体实际操做还没去实现,若是理解错误帮忙指正。
UILabel *myLabel = [UILabel new]; /* UIFont 的preferredFontForTextStyle: 意思是指定一个样式,并让字体大小符合用户设定的字体大小。 */ myLabel.font =[UIFont preferredFontForTextStyle: 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;
iOS 10 之后只要是继承UIScrollView
那么就支持刷新功能:
@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(10_0) __TVOS_PROHIBITED;
判断系统版本是咱们常常用到的,尤为是如今你们都有可能须要适配iOS 10,那么问题就出现了,以下图:
咱们获得了答案是:
//值为 1 [[[[UIDevice currentDevice] systemVersion] substringToIndex:1] integerValue] //值为10.000000 [[UIDevice currentDevice] systemVersion].floatValue, //值为10.0 [[UIDevice currentDevice] systemVersion]
因此说判断系统方法最好仍是用后面的两种方法,哦~我忘记说了[[UIDevice currentDevice] systemVersion].floatValue
这个方法也是不靠谱的,好像在8.3
版本输出的值是8.2
,记不清楚了反正是不靠谱的,因此建议你们用[[UIDevice currentDevice] systemVersion]
这个方法!
Swift判断以下:
if #available(iOS 10.0, *) { // iOS 10.0 print("iOS 10.0"); } else { }