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屬性只支持徹底匹配,若是想要符合全部的一級二級域名,用*號字符開頭。