Important:html
This is a preliminary document for an API or technology in development. Apple is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein for use on Apple-branded products. This information is subject to change, and software implemented according to this document should be tested with final operating system software and final documentation. Newer versions of this document may be provided with future betas of the API or technology.ios
Contents:git
Introductionweb
iOS SDK 9.0 provides support for developing iOS apps. It is packaged with a complete set of Xcode tools, compilers, and frameworks for creating apps for iOS and OS X. These tools include the Xcode IDE and the Instruments analysis tool, among many others.算法
With this software you can develop apps for iPhone, iPad, or iPod touch running iOS 9. You can also test your apps using the included Simulator, which supports iOS 9. iOS SDK 9.0 requires a Mac computer running OS X v10.10.3 (Yosemite) or later.windows
This version of iOS is intended for installation only on devices registered with the Apple Developer Program. Attempting to install this version of iOS in an unauthorized manner could put your device in an unusable state.api
For more information and additional support resources, visit http://developer.apple.com/programs/ios/.浏览器
iOS9系统如今须要开发者帐号注册的设备才能更新。若是没有受权强行安装,可能会出现不可控的问题。 安全
Bug Reporting服务器
For issues not mentioned in the Notes and Known Issues section, please file bugs through the Apple Developer website (https://developer.apple.com/bug-reporting/ios/). Additionally, you may discuss these issues and iOS SDK 9.0 in the Apple Developer Forums. To get more information about iCloud for Developers, go to http://developer.apple.com/icloud.
Notes and Known Issues
The following issues relate to using iOS SDK 9.0 to develop code.
App Store
Note
iOS 9 enforces the UILaunchImages requirement; apps can no longer declare the same launch image to support different interface orientations.
iOS9强制使用UILaunchImages, App再也不须要为不一样的屏幕方向指定同一张启动图。
Known Issue
Users might be prompted twice for credentials on the first In-App Purchase.
第一次使用程序内购买的时候,用户可能须要俩次身份验证。
Apple ID
Notes
- Some users will be offered to turn on two-factor authentication on their Apple ID. For more information about two-factor authentication see developer.apple.com/support/two-factor-authentication.
- If you turn on two-factor authentication on your Apple ID, iTunes purchases on Mac and Windows and store purchases on Apple TV will require you to append a six-digit verification code to the end of your password the first time you use that device. The six-digit code will display automatically on your iOS 9 or OS X El Capitan devices, or can be sent to your trusted phone number via a text message or phone call.
在使用AppleID时,一些用户可能须要二次受权。若是你开启了双重认证, 当你在mac系统或windows系统或者Apple TV中购买产品时,若是是第一次在这个设备上使用,会要求提供一个六位的安全码, 这个安全码会显示在你的iOS9系统或者OS X El Capitan系统设备上,或者以信息方式发送到你的手机或者一个语音电话。
Apple Pay
Note
The format of the postal code that is returned prior to full authorization has changed from iOS 8. In some cases, it may be truncated from what was previously being returned.
彻底受权时使用的postal code从iOS8系统开始发生改变。 在一些状况下会比以前的缩短。
AVFoundation
Notes
- The canUseNetworkResourcesForLiveStreamingWhilePaused property has been added to AVPlayerItem. The default value is NO for apps linked on or after iOS 9.0 or OS X 10.11, but YES for apps that were linked earlier.To minimize power usage, set this property to NO if you do not need playback state to stay up to date while paused.
新属性canUseNetworkResourcesForLiveStreamingWhilePaused, iOS9系统之前默认开启,iOS9默认关闭,若是须要减小性能消耗,在视频流暂停的时候,若是不须要使用播放状态能够把这个属性设为关闭。
- AVQueuePlayer now supports a mixture of file-based media and HTTP Live Streaming media in its queue. Prior to this, you had to ensure that all items in the queue were of the same type.
- AVQueuePlayer 如今支持基于本地文件和网络流媒体的视频流,因此,你必须保证队列中全部的内容是同一种类型。
- For apps linked against iOS 9 or later, the media interruption behavior for AV(Queue)Player has changed.Before iOS 9, apps could interrupt other media-playing clients by associating or adding AVPlayerItem to AVPlayer or by modifying the time or date of the current AVPlayerItem (using the seekToTime: or seekToDate: methods). In iOS 9, these operations interrupt only when AVPlayer object’s playback rate is changed to a non-zero value through the rate property or play method.
iOS9之后,AVPlayer和AVQueuePlayer 的中断行为发生变化, iOS9之前,App在使用AVPlayerItem、AVPlayer时,或者修改AVPlayerItem的播放时间,会打断其余正在播放的客户端,在iOS9系统,这些操做只有在rate值非0的时候才会打断 (rate是正常播放和快速播放的频率,在暂停的时候rate值为0), 或者在调用play函数的时候打断。
大概意思是说,之前其余软件正在播放,进入当前软件,一调用相关函数,正在播放的软件就会中止, 如今不会了, 只有在当前软件正在播放或者开始播放的时候,才会打断以前的软件。
- Picture in Picture playback might stop and the Picture in Picture button might disappear when using AVPlayerViewController for video playback and replacing the underlying AVPlayer object’s current item using replaceCurrentItemWithPlayerItem:.
在使用AVPlayerViewController播放视频而且使用replaceCurrentItemWithPlayerItem方法,替换当前AVPlayer的播放视频对象时,画中画功能可能会中止而且画中画按钮会消失。
- The cancelPictureInPicture method is deprecated. 取消画中画函数过期,再也不建议使用。
Bluetooth
Known Issue
Pairing a Miura MFI accessory to an iOS 9 device will not work. Miura认证的蓝牙功能在iOS9系统再也不支持。
Workaround: Do not remove pairing after updating to iOS 9. 提醒: 在升级iOS9以后,不要移除配对。
CBCentralManager
Note
The retrievePeripherals: and retrieveConnectedPeripherals methods were deprecated in iOS 7.0 and removed in iOS 9.0. Apps that use these methods will crash on launch or upon pairing an accessory.
retrievePeripherals retrieveConnectedPeripherals 方法在iOS7系统过期,如今在iOS9系统禁止使用,App若是使用这俩个函数会崩溃。
Foundation
Notes
省电模式下提供新的Api函数。
Whenever possible, batch and reduce network operations, and avoid unnecessary updates to the user interface. Power-intensive operations should be under the user’s control. If a user is playing a graphics-heavy game, for example, the user should not be surprised if the activity consumes power. Strive to make your app absolutely idle when it is not responding to user input.
在省电模式下,尽量减小网络请求,避免没必要要的界面刷新,消耗电量的操做应该由用户主动发起。若是用户正在玩大型游戏时,不该该让用户对电量的消耗感到太惊讶,尽可能保证让用户再也不操做时,App是彻底空闲状态。
省电模式连接:https://developer.apple.com/library/prerelease/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/index.html#//apple_ref/doc/uid/TP40015243
- Horizontal location constraints should consistently reference either left/right or leading/trailing attributes. For apps linked against the iOS 9 SDK, NSLayoutConstraint will throw an exception if you attempt to create a constraint between a leading/trailing attribute and a left/right attribute.
水平坐标布局,须要遵循左右和先后对齐属性。 在iOS9里面, 若是你试图建立的布局会致使左右和先后对齐方式冲突,NSLayoutConstraint会抛出异常。
iCloud Drive
Note
The fetchAllChanges property on CKFetchRecordChangesOperation has been deprecated, and will be removed in iOS 9.
CKFetchRecordChangesOperation 的fetchAllChanges属性过期,iOS9系统禁止使用。
Keyboards
Note
The setting to use a third-party keyboard as the default keyboard for text input is not always respected.
默认使用第三方键盘(百度、搜狗等)的设置,不会一直遵照。
Keychain
Note
iCloud Keychain will not sync passwords and credit cards with betas of iOS 9 and OS X El Capitan.
iOS9和OS X El Capitan,系统不会同步密码和银行卡。
Music
Note
When users plug in headphones or connect to Bluetooth or CarPlay in their car, their favorite music app appears on the lock screen or the car display.
当你连上耳机、蓝牙或者车载播放器时,最喜欢的音乐会显示在手机屏幕或者车载播放器屏幕上。
For your app to be eligible for this, it must publish to Now Playing upon launch and consistently maintain a Now Playing state. A common practice upon launch is to continue playing the track from when the app was last exited.
若是想要你的App支持这个功能,App必须设计成启动时播放,而且能够一直保持播放状态。一个简单的作法是,当App是最后一个关闭的音乐播放App时,仍然能够继续控制播放音乐。
Known Issue
Some tracks you have previously purchased won’t play.
提示: 你以前购买的一些音乐不会播放。
Workaround: Sign out of the Store and then sign back in.
方案:退出Store,而后再次登陆。
Networking
Notes
- When negotiating a TLS/SSL connection with Diffie-Hellman key exchange, iOS 9 requires a 1024-bit group or larger. These connections include:
- Secure Web (HTTPS)
- Enterprise Wi-Fi (802.1X)
- Secure e-mail (IMAP, POP, SMTP)
- Printing servers (IPPS)
- DHE_RSA cipher suites are now disabled by defaults in Secure Transport for TLS clients. This may cause failure to connect to TLS servers that only support DHE_RSA cipher suites. Applications that explicitly enable cipher suites using SSLSetEnabledCiphers are not affected and will still use DHE_RSA cipher suites if explicitly enabled.Safari may see a “Safari can’t establish a secure connection to the server” error page. Safari and other clients of CFNetwork API (NSURLSession, NSURLConnection, CFHTTPStream, CFSocketStream and Cocoa equivalent) will show “CFNetwork SSLHandshake failed” error in Console.
当使用Diffie-Hellman加密算法作TLS/SSL链接通讯时,iOS9 系统要求1024位或者更大。 这些链接包括:
- Https Web通讯
- 企业WiFi 802.1x认证
- 安全的邮箱认证 包括IMAP, POP, SMTP格式。
- IPPS格式的打印服务
DHE_RSA加密方案在iOS9系统默认禁止用来作TLS客户端的安全通讯, 这可能致使链接只支持DHE_RSA 加密算法方案的TLS服务器时链接失败。 App能够开启SSLSetEnabledCiphers, 而后能够仍然使用DHE_RSA加密方案。
Safari浏览器可能会在错误页面上显示“Safari不能建立一个安全的通讯链接”。Safari和其余相似的使用CFNetwork API(包括NSURLSession, NSURLConnection, CFHTTPStream, CFSocketStream and Cocoa equivalent)的客户端,会在控制台显示“ CFNetwork SSLHandshake failed” 出错信息。
On-Demand Resources
Known Issue
New or changed on-demand resource assets packs that are added or changed as part of an app update may be inaccessible to the application.
Workaround: Include the new or updated asset packs directly in the application bundle.
按需加载资源
提示:在App更新时,新增长或者修改的资源文件,可能会出现没法访问的状况。
解决方案:把新增长或修改的资源文件,直接放到App安装包。
ReplayKit
Known Issue
Playing a video while ReplayKit recording is ON stops the ongoing recording session and the video fails to play.
播放视频时,若是ReplayKit的录制开关是开启状态,会致使出现中止正在进行的录制进程,而且播放视频失败。
Restore
Known Issue
If you’ve set a region that doesn’t match your language, restores from iCloud Backup might not progress.
若是你设置了不符合你的系统语言的时区,iCloud备份还原可能不会运行。
Workaround: During restore, change your region to match your language. You can change it back after the restore is over.
提示: 在还原时,把你的时区改为跟你的系统语言一致,你能够在还原成功后再改回来。
Safari
Notes
- When Done is tapped in a SFSafariViewController, it is automatically dismissed. You no longer need to dismiss it in the delegate method safariViewControllerDidFinish:.
- “Find on Page” is now available both from the Share sheet as well as in the Completions List.
- Request Desktop Site has moved; it’s now in the Share sheet instead of Favorites.
- Web Browser–to–Native App Handoff does not work with your app if the apple-app-site-association file isn’t correctly formatted and signed. For more information, see Handoff Programming Guide and Shared Web Credentials Reference.
- 当点击SFSafariViewController界面中的完成按钮时,网页窗口会自动关闭。你不须要再本身调用dismiss方法。
- “在页面中查找” 功能如今能够在分享插件(Share sheet)和完成列表(Completions List)中,同样可使用。
- Request Desktop Site(本地主页)被移除,它如今放到“共享的连接”里面,而不是之前的“我的收藏”。
- 网页版App的handoff同步功能, 若是App的相关文件不是正确的格式或者签名,handoff功能会不可用。
Use SFSafariViewController if your app lets users view websites from anywhere on the Internet. UseWKWebView if your app customizes, interacts with, or controls the display of web content.
iOS9新增 SFSafariViewController,能够在App中任何地方调用来浏览网站, 若是你想要定制网页显示内容,仍是使用WKWebView。
Secure Transport
Note
DHE_RSA cipher suites are now disabled by default in Secure Transport for TLS clients. This may cause failure to connect to TLS servers that only support DHE_RSA cipher suites. Applications that explicitly enable cipher suites using SSLSetEnabledCiphers are not affected and will still use DHE_RSA cipher suites if explicitly enabled.
DHE_RSA密钥算法在TLS平台安全数据传输时默认禁用, 这可能致使只支持DHE_RSA密钥算法的TLS认证服务器链接失败。 App设置属性SSLSetEnabledCiphers开启时不受影响,能够继续使用DHE_RSA密钥算法。
UIKit
Notes
- If initialized with a nil nibName value, UIViewController.nibName has always looked for a nib with a similar name as the view controller’s class, and defaulted to that value if loadView is not overridden.Prior to iOS 9, subclasses of UIViewController that were written in Swift would require that their corresponding nib file name include the module prefix.
To improve flexibility in the event of refactoring, you can omit the module name from the nib filename in code that runs in iOS 9. UIViewController.nibName still prefers a name that contains the module prefix, but falls back to an unqualified name if a nib with the fully-qualified name is not found.
- In iOS 9, when layoutIfNeeded is sent to a view and all of the following conditions are satisfied (which is not common), we apply fitting-size constraints (width/height = 0 at UILayoutPriorityFittingSizeLevel) instead of required size constraints (width/height required to match current size):
- The receiver is not yet in the subtree of a view that hosts a layout engine, such as window, view controller view (unless you have set translatesAutoresizingMaskIntoConstraints to NO on that view—or created constraints that have one item in its subtree and one item outside it), table view cell content view, and so on.
- The final ancestor (that is, top-level view) of the receiver has translatesAutoresizingMaskIntoConstraints set to NO.
- The top-level view has a subview that is not a UIViewController-owned layout guide that also has translatesAutoresizingMaskIntoConstraints set to NO.
- Under condition 1, we create a temporary layout engine from the top-level view and add all the constraints from the subtree to it. The problem is that we need to add some constraints that make the size of the top-level view unambiguous in the layout engine. The old behavior (prior to iOS 9) was that we would add constraints to restrict the size of the top-level view to its current bounds for any situation under condition 1. This really doesn’t make sense when you add conditions 2 and 3 and can result in unsatisfiable-constraints logging and broken layout.So in iOS 9, for this special case only, we use fitting-size constraints instead.
This means that if you are sending layoutIfNeeded to a view under these conditions in iOS 9, you must be sure that either you have sufficient constraints to establish a size for the top-level view (which usually, though not always, is the receiver) or you must add temporary size constraints to the top-level view of layout size you desire before sending layoutIfNeeded, and remove them afterward.
- For apps linked on iOS 9 or later, UITextView will now always correctly constrict its NSTextContainer to the fit inside the view when scrolling is disabled. Overflowing lines that lie outside of an NSTextContainer, even partially, are not rendered.In previous iOS releases, the NSTextContainer sometimes was not constricted in size. This meant that logically overflowing lines were erroneously rendered. If you are seeing previously rendered lines at the end of your text view no longer rendered after linking your app against iOS 9, this behavior change is the likely cause. You can remedy this by making your UITextView larger, or perhaps by adjusting the bottom value of the text view's textContainerInset property.
- There is a redesigned UI for printing that includes a print preview (presented from UIPrintInteractionController or UIActivityViewController). For apps that provide printing items or use only built-in UIPrintFormatter objects (such as UISimpleTextPrintFormatter,UIMarkupTextPrintFormatter, UIWebViewPrintFormatter, or the UIViewPrintFormatter of any system-provided view), nothing additional is needed for the print preview to display.Apps that subclass UIPrintPageRenderer or UIPrintFormatter to draw content for printing must be built with the iOS 9 SDK for the preview to display. The behavior of UIPrintPageRenderer has been updated to call drawPageAtIndex:inRect: multiple times with potentially different page sizes and margins. Various methods on UIPrintPageRenderer may be called from a non-main thread, but never from multiple threads concurrently.
- UIPickerView and UIDatePicker are now resizable and adaptive—previously, these views would enforce a default size even if you attempted to resize them. These views also now default to a width of 320 points on all devices, instead of to the device width on iPhone.Interfaces that rely on the old enforcement of the default size will likely look wrong when compiled for iOS 9. Any problems encountered can be resolved by fully constraining or sizing picker views to the desired size instead of relying on implicit behavior.
若是初始化UIViewController时,传递的nibName属性是nil, 那么UIViewController的nibName属性会一直被锁住为跟当前Controller类一个名字的nib, 而且一直是这个值除非loadView方法被重写。在iOS9之前,使用Swift语言写的UIViewController的子类,会要求必须填写合适的nib文件名字。为了改善重构时自由度体验,你能够在iOS9中忽略写这个名字。UIViewController.nibName会优先寻找里面包含Controller类名前缀的,若是找不到彻底符合名字的nib,会返回不合格的。
在iOS9里面,当layoutIfNeeded方法在一个view对象调用时,而且下列全部的条件知足,咱们使用fitting-size约束,而不是要求大小约束合格。
一、接收者不是宿主view的子view,例如window,Controller的view(除非你在view建立时,把translatesAutoresizingMaskIntoConstraints 属性设置为NO,或者建立约束时有一个是子view,另外一个是view外), tableview 、cell content view 等等。
二、当前view层级的最后一个view,的属性translatesAutoresizingMaskIntoConstraints 设置为NO;
三、最高层view有一个子view,而且不归controller控制布局,它的translatesAutoresizingMaskIntoConstraints 也设置为NO。
对于条件1,咱们对最高层view建立一个临时的layout约束,而且把全部子view的约束添加给它。 问题是咱们须要添加一些约束,用来让最高层view的size明确起来。 iOS9之前,咱们须要添加一些约束给最高层view来适应它当前的bounds来知足条件1。 当你增长条件二、3的约束时这会不起做用,致使不可控的约束进而破坏界面布局。
因此在iOS9里面,对于这种特殊的情形,咱们用fitting-size约束来代替。
这意味着,在iOS9系统里面当你对一个知足上述条件的view调用layoutIfNeeded方法时,你必须确保,或者你已经对最高层view设置了size大小, 或者在调用方法前你必须对最高层view添加临时的size约束,而且随后移除size约束。
对iOS9之后的App,UITextView 当滚动属性被禁用时,会始终修改它的NSTextContainer,来知足view中的显示内容。 溢出NSTextContainer的线,或者是一部分线,不会显示。
在iOS9之前,NSTextContainer有时候不受size大小约束,这意思是说,溢出的线会错误的显示出来。若是你之前看到过溢出的线在textview底部显示了,可是如今再也不显示,就是这个行为改变的。你能够补救这个问题,经过放大UITextView,或者多是经过textContainerInset属性设置textview的底部边距。
对打印功能来讲,打印预览界面被从新设计, 对提供打印功能的App来讲,或者是使用到UIPrintFormatter对象,不须要附加其余因素就能够显示预览界面。
在App里,若是继承了UIPrintPageRenderer 或者 UIPrintFormatter类,必须使用iOS9的sdk来实现预览。 UIPrintPageRenderer 的行为,已经更改成使用drawPageAtIndex:inRect方法,对不一样的界面大小和边缘会调用屡次。更多相关UIPrintPageRenderer的方法会在非主线程被调用,可是不会同一时间在多个线程执行。
UIPickerView和UIDatePicker 如今大小可调和自适应,之前若是你想修改它们,它们的视图会强制使用一个默认的大小。 如今它们的视图会在全部的设备类型上默认使用320宽度,而不是iPhone手机的设备宽度。
当用iOS9编译时,依赖于默认大小的界面可能会出错。 任何由于这个修改致使的问题,能够经过完整的约束,或者修改picker view的尺寸来解决,而不是依赖于其余不明行为。
Webkit
Note
The if-domain and unless-domain value strings only match the exact domain. To match the domain and any subdomains, begin the string with the asterisk character (*).
使用Webkit时,if-domain、unless-domain属性只支持彻底匹配,若是想要符合全部的一级二级域名,用*号字符开头。