本文將繼續(xù)介紹iOS7中的新特徵_第1頁
本文將繼續(xù)介紹iOS7中的新特徵_第2頁
本文將繼續(xù)介紹iOS7中的新特徵_第3頁
本文將繼續(xù)介紹iOS7中的新特徵_第4頁
本文將繼續(xù)介紹iOS7中的新特徵_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、本文將繼續(xù)介紹iOS7中的新特徵,包括:已有Framework的改進(jìn)、Objective-C和已經(jīng)過 時(shí)的API。 注1 :本文是關(guān)於新特徵介紹的最後一篇,隨後的博文,以wwdc2013內(nèi)容爲(wèi)主,歡 迎大家關(guān)注! 已有Framework 的改進(jìn)(19個(gè)) 下面我們來看看iOS7中有明顯修改的一些 framework。如果要查看完整的新介面,請(qǐng)查看 iOS 7.0 API Diffs。本部分內(nèi)容看起來可能稍顯枯燥,並且我沒有對(duì)其做配圖,所以讀者可 以挑選自己感興趣的部分進(jìn)行閱讀也不妨。 UIKit Framework UIKit Framework(UIKit.framework) 主要做了如下

2、改進(jìn): 1、 所有的使用者介面控制項(xiàng)都做了更新,以與iOS7相適應(yīng)。 2、UIKit動(dòng)力可以讓開發(fā)者模擬現(xiàn)實(shí)世界中的一些效果,例如在動(dòng)畫中使用重力行爲(wèi)。 3、Text Kit提供了複雜的文字編輯和顯示功能。 4、UIView類新增加了如下內(nèi)容: tintColor屬性:可以使用一個(gè) tint color,並對(duì)view和它的subview有影響。關(guān)於如何使用 tint colors,請(qǐng)看 iOS 7 UI Tran sition Guide 。 1. /* 2. -tintColor always returns a color. The color returned is the fi rst

3、 non-default value in the receivers superview cha in (starti ng with itself). 3. If no non-default value is found, a system-defined color is ret urn ed. 4. If this views -tintAdjustmentMode returns Dimmed, then the col or that is returned for -ti ntColor will automatically be dimmed 5. If your view

4、subclass uses tintColor in its rendering, override -tintColorDidChange in order to refresh the rendering if the c olor cha nges. 6. */ 7. property(nonatomic,retain) UIColor *tintColor NS_AVAILABLEOS (7_0); 8. 8. /* 特別是阻止 通過view可以創(chuàng)建基於關(guān)鍵幀的動(dòng)畫。同樣也可以對(duì)view做出改變 任意正在執(zhí)行的動(dòng)畫。 5、UIViewController 類新增了如下內(nèi)容: View

5、controller 之間的切換(transition)可以自訂、驅(qū)動(dòng)式交互(driven interactively),或者完 全根據(jù)自己指定的切換方式來替換。 可以通過程式設(shè)計(jì)的方式指定View con troller 資訊來管理status bar style。當(dāng)然,在程式的 UIViewC on trollerBasedStatusBarAppeara nee 的幾個(gè)用來指定status bar的方法 的status bar和visibility。系統(tǒng)會(huì)根據(jù)提供的 info.plist檔中,設(shè)置 鍵值也是可以的。如下代碼是iOS7中新增 1. / These methods contr

6、ol the attributes of the status bar when this view con troller is show n. They can be overridde n in view c on troller subclasses to retur n the desired status bar attribute s. 2. - (UIStatusBarStyle)preferredStatusBarStyle; 3. - (BOOL)prefersStatusBarHidden; 4. 4. / This should be called whenever t

7、he return values for the vie w controllers status bar attributes have changed. If it is cal led from within an animation block, the changes will be animate d along with the rest of the ani mati on block. 5. - (void)setNeedsStatusBarAppearanceUpdate; 6、 UIMoti on Effect類爲(wèi)運(yùn)動(dòng)效果定義了一些基本的行爲(wèi)一一定義了一個(gè)view如何響應(yīng)

8、基於 設(shè)備的運(yùn)動(dòng)。 7、 Collection view 支援 UlKit 動(dòng)力(UlKit Dynamic) 這樣可以將一些行爲(wèi)物件 (behavior object)應(yīng)用到 Collection view 的 layout attribute 中,以對(duì) collection view 中的 item 做出相 應(yīng)的動(dòng)畫。 8、 UIImage的ImageNamed:方法可以把檢索存儲(chǔ)在asset目錄中的圖片,這就提供了一種 方法一一管理並優(yōu)化具有多種尺寸和解析度的資源。 9、 UIView和UIScreen提供了一個(gè)新的方法:snapshot返回一個(gè)view,可以用來顯示 程式的內(nèi)容。 1.

9、 /* Creating snapshots from existing snapshots (as a method to d uplicate, crop or create a resizable varia nt) is supported. In cases where many sn apshots are n eeded, creati ng a sn apshot from a com mon superview and making subseque nt sn apshots from it can be more performa nt. 2. */ 3. interfa

10、ce UIView (UISnapshotting) 4. - (UIView *)snapshot NS_AVAILABLE_IOS(7_0); 5. - (UIView *)resizableSnapshotFromRect:(CGRect)rect withCaplnset s:(UIEdgeI nsets)capl nsets NS_AVAILABLEO S(7_0); / Resizable s n apshots will default to stretchi ng the cen ter 6. end 1. interface UIScreen (UISnapshotting)

11、 2. - (UIView *)snapshot NS_AVAILABLE_IOS(7_0); 3. end 10、UIKeyCommand 類封裝了從週邊硬體鍵盤接收到的鍵盤事件。這些事件會(huì)被分發(fā) (delivered)到程式的回應(yīng)鏈(responder chain)中以被處理。 11、 UIFontDescriptor 物件使用一個(gè)屬性字典來描述字體。通過font descriptor可以與其它 平臺(tái)相互交互。 12、UIFont和UIFontDescriptor類支援動(dòng)態(tài)調(diào)整字體大小,這樣可以增加程式中文字的易 讀性一一使用者可以控制所有程式的字體大小。 13、 UIActivity類現(xiàn)

12、在支持新的一些 activity類型,包括通過 AirDrop發(fā)送資料,給內(nèi)容到 Safari閱讀清單中,把資料發(fā)送到 Flickr、Tencent Weibo 和Vimeo。 14、 UIApplicationDelegate 協(xié)定新增了處理後臺(tái)獲取資料的操作。 1. /*! This delegate method offers an opportunity for applications with the remote-no tificati on backgro und mode to fetch approp riate new data in response to an inc

13、oming remote notification. You should call the fetchCompletio nHan dler as soon as youre fi ni shed perform ing that operati on, so the system can accurately estimate its power and data cost. 2. 3. This method will be invoked even if the application was launche d or resumed because of the remote no

14、tificatio n. The respective delegate methods will be inv oked first. Note that this behavio r is in contrast to application:didReceiveRemoteNotification:, which is not called in those cases, and which will not be invok ed if this method is impleme nted. !*/ 4. - (void)application:(UIApplication *)ap

15、plication didReceiveRemo teNotificati on :(NSDict ionary *)userI nfo fetchCompletio nHan dler: (void (A)(UIBackgrou ndFetchResult result)completio nHan dler NS_ AVAILABLEO S(7_0); 5. 5. / Applications with the fetch background mode may be given opport un ities to fetch updated content in the backgro

16、 und or whe n it is convenient for the system. This method will be called i n these situati ons. You should call the fetchCompletio nHan dler as soon as youre finished performing that operation, so the sy stem can accurately estimate its power and data cost. 6. - (void)application:(UIApplication *)a

17、pplication performFetchWi thCompletio nHa ndler:(void (A)(UIBackgrou ndFetchResult result)c ompletio nHan dler NS_AVAILABLE_IOS(7_0); 8. 9. / Applications using an NSURLSession with a background configu rati on may be laun ched or resumed in the backgro und in order to han dle the 9. / completi on o

18、f tasks in that sessi on, or to han die authe ntica tion. This method will be called with the identifier of the ses sion n eed ing 10. / attention. Once a session has been created from a configurat ion object with that identifier, the sessions delegate will be gin recei ving 11. / callbacks. If such

19、 a sessi on has already bee n created (if th e app is being resumed, for in sta nee), the n the delegate will s tart recei ving 12. / callbacks without any action by the application. You should call the completionHandler as soon as youre finished handling the callbacks. 13. - (void)application:(UIAp

20、plication *)application handleEventsFo rBackgroundURLSession:(NSString *)identifier completionHandler: (void (A)()completio nHan dler NS_AVAILABLE_IOS(7_0); 15、UlKit新增了引導(dǎo)訪問模式(guided-access mode)運(yùn)行程式自己鎖定,以防止被用 戶修改。這樣的功能主要是為一些機(jī)構(gòu)設(shè)計(jì)的 ,例如在學(xué)校一一學(xué)生雖然攜帶了他們的設(shè)備 但是需要運(yùn)行由學(xué)校提供的程式。 16、 State還原功能運(yùn)行保存和還原任意的物件。遵循UlSta

21、teRestoring 協(xié)定的物件,當(dāng)程 式被切換到後臺(tái)(background)時(shí),可以把狀態(tài)資訊保存起來,之後程式被啟動(dòng)時(shí),這些狀 態(tài)可以被還原。 17、Table view 支援對(duì)row或其他元素高度的評(píng)估 (estimating),這樣可以提升 Table view 的滾動(dòng)性能。 更多關(guān)於 UlKit framework 的內(nèi)容,請(qǐng)閱讀 UlKit Framework Referenee Store Kit Framework Store Kit framework(StoreKit.framework)已經(jīng)遷移到新的訂單系統(tǒng) (receipt system),這樣 一來,開發(fā)者可以在自

22、己的設(shè)備上驗(yàn)證內(nèi)購(in-app purchase)。同樣也可以在伺服器上進(jìn)行 程式購買訂單的驗(yàn)證。 更多關(guān)於新訂單系統(tǒng)的使用,請(qǐng)閱讀:Receipt Validation Programmi ng Guide 。 Security Framework Security Framework(Security.framework)現(xiàn)在支持:通過 iCloud,可以把密碼在使用者兩 臺(tái)設(shè)備間進(jìn)行同步。通過新的keychain屬性(kSecAttrSyncronizable),程式可以爲(wèi)iCloud 標(biāo)記它們的keychain item 。 更多相關(guān)這個(gè)屬性的內(nèi)容,請(qǐng)看該 framework的標(biāo)頭檔

23、。關(guān)於keychain更多資訊,請(qǐng)看 Keycha in Services Program ming Guide 。 Pass Kit Framework Pass Kit Framework(PassKit.ramework)新增了一些 API針對(duì)同時(shí)添加多個(gè)通行證 (pass),通行證檔的格式也做了相應(yīng)的調(diào)整: 1. 新的key指定通行證的截止日期 2. 可以指定通行證只與特定的藍(lán)牙信號(hào)相關(guān) 3. 利用新的屬性來控制通行證的顯示。可以把通行證進(jìn)行歸類,並在通行證的背面顯示自訂 的文字內(nèi)容,以及控制顯示在通行證上的時(shí)間值 4. 可以給通行證附帶一些額外的資料資訊,在程式中可以使用這些資料,不

24、過並直接顯示給 使用者 5. 可以指定那些data detector用於通行證的欄位中 更多關(guān)於如何在程式中使用Pass Kit的資訊,請(qǐng)閱讀 Passbook Programming Guide。關(guān)於 通行證檔的格式,請(qǐng)閱讀Passbook Package Format Refere nee。 Ope nGL ES OpenGL ES做了如下新的擴(kuò)展: 1. EXT_SRGB 支援sRBG框架緩衝區(qū)(framebuffer)操作 2. GL_APPLE_pvrtc_sRGB支援將sRGB紋理資料壓縮爲(wèi) PVRTC紋理格式 3. GL_APPLE_draw_instaneed和 GL_APPL

25、E_draw_arrays 可以提升渲染的速度-當(dāng)程式 在繪製多個(gè)相同的實(shí)例物件時(shí)。 現(xiàn)在可以在vertex shaders 中訪問紋理了;通過 MAX_VERTEX_TEXTURE_IMAGE_UNITS屬性決定你可以訪問紋理的準(zhǔn)確數(shù)目。 MessageUI Framework 在 MessageUI framework 中,MFMessageComposeViewController 現(xiàn)在可以支援將附件添 加到資訊中。關(guān)於新介面內(nèi)容,可以參看framework標(biāo)頭檔。關(guān)於這個(gè) framework的類, 請(qǐng)閱讀 Message UI Framework Referenee。 Media Pl

26、ayer Framework 在Media Player framework 中,MPVolumeView 類可以判斷用戶選擇的無線路由(wireless route,例如AirPlay和Bluetooth)是否可用。你也可以判斷無線路由當(dāng)前是否可用。關(guān)於新 介面資訊,請(qǐng)參看framework的頭文件。關(guān)於Media Player framework涉及到的類,請(qǐng)參 看 Media Player Framework Referenee 。 Map Kit Framework 關(guān)於Map Kit framework 相關(guān)修改,筆者已經(jīng)在這裡介紹過:iOS7新特徵匯總02:遊戲、 地圖以及AirD

27、rop 更多相關(guān)資訊,請(qǐng)查閱Map Kit Framework Refere nee。 Image I/O Framework Image I/O Framework(ImageIO.framework)現(xiàn)在提供了獲取和設(shè)置 image metadata 的介面。 更多相關(guān)介面資訊,請(qǐng)看 framework的標(biāo)頭檔。關(guān)於framework類的介紹,請(qǐng)看Image I/O Refere nee Colleetio n 。 iAd Framework iAd framework(iAd.framework) 做了如下修改讓廣告更好的融入到程式中: 在MPMoviePlayerController類

28、中的新方法可以讓你在播放電影之前運(yùn)行廣告 view controller進(jìn)行適當(dāng)?shù)呐渲迷趯?shí)際內(nèi)容顯示之前先顯示出廣告內(nèi)容。 關(guān)於新介面請(qǐng)看framework中的標(biāo)頭檔。關(guān)於 framework的介紹,請(qǐng)看 Ad Support Framework Refere nee 。 Game Kit Framework 關(guān)於Game Kit Framework(GameKit.framework)的改變,已經(jīng)在這裡介紹過:iOS7新特徵 匯總02:遊戲、地圖以及 AirDrop 更多相關(guān)介紹,請(qǐng)看 Game Kit Framework Refere nee 。 Foun dati on Framewor

29、k Foun dati on framework(F oun dati on. framework)主要做了如下改進(jìn): I. NSURLSessi on 類是一個(gè)新增的類,主要用於程式在後臺(tái)運(yùn)行時(shí),對(duì)網(wǎng)路資源的操 作。這個(gè)類替換了 NSURLConnection 和相關(guān)delegate ;同樣也替換了 NSURLDownload 和相關(guān)delegate 。 2. NSURLComponents 類也是一個(gè)新增類一一用來解析URL的構(gòu)建。這個(gè)類在解析URL 的時(shí)候支持URI標(biāo)準(zhǔn)(rfc3986/STD66)。 3. NSNetService 和NSNetServiceBrowser 用於在藍(lán)牙和

30、Wi-Fi中點(diǎn)對(duì)點(diǎn)的查找。 4. NSURLCredential 和NSURLCredentialStorage兩個(gè)類可以用來創(chuàng)建同步策略的證書,並 可以從iCloud中移除相關(guān)同步策略證書。 5. NSURLCache、NSURLCredentialStorage和 NSHTTPCookieStorage三個(gè)類支援存儲(chǔ)請(qǐng) 求的非同步處理。 6. NSCalendar類支持新的日曆類型。 更多關(guān)於新的介面,請(qǐng)看 framework中 大標(biāo)頭檔和 Foundation release notes 。關(guān)於該 framework 類的介紹,請(qǐng)看 Foundation Framework Refere

31、nce 。 Core Teleph ony Framework Core Teleph ony framework(CoreTelepho ny.framework)現(xiàn)在可以獲取到設(shè)備使用的無線電 資訊:當(dāng)前的信號(hào)強(qiáng)度、cell ID。由運(yùn)營商開發(fā)的相關(guān)程式,同樣可以通過預(yù)定運(yùn)營商相關(guān) 服務(wù),來對(duì)他們的程式進(jìn)行驗(yàn)證。 更多相關(guān)資訊請(qǐng)看 Core Telepho ny Framework Refere nee。 Core Moti on Framework Core Motion framework(CoreMotion.framework)現(xiàn)在支持 step counting(類似計(jì)步器)和運(yùn)

32、 動(dòng)的跟蹤。關(guān)於 step countingframework通過檢測(cè)使用者的運(yùn)動(dòng),然後根據(jù)運(yùn)動(dòng)資訊 計(jì)算出步數(shù)(貌似很牛叉的樣子,不知道準(zhǔn)確度如何了)。由於運(yùn)動(dòng)資訊是由系統(tǒng)檢測(cè)的, 所以即使當(dāng)程式?jīng)]有運(yùn)行的時(shí)候,系統(tǒng)也可以持續(xù)的收集step資料。通過這樣的功能, framework也能區(qū)分出不同的運(yùn)動(dòng)類型,例如walking、running或者automobile這對(duì) 於導(dǎo)航類程式來說,就可以使用這些資料,直接修改使用者的運(yùn)動(dòng)類型。 更多相關(guān)資訊,請(qǐng)看 Core Motion Framework Refere nee Core Locati on Framework Core Locatio

33、n framework(CoreLocatio n. framework)可以通過藍(lán)牙設(shè)備來測(cè)距。通過測(cè)距可 以確定附近藍(lán)牙設(shè)備的範(fàn)圍,並作出相應(yīng)的反應(yīng)。例如,在博物館的畫廊裡面,可能有一 些藍(lán)牙信號(hào),供參觀者通過相關(guān)程式顯示出畫廊的入口和出口。framework還支援推遲位置 的更新的通知,直到特定的時(shí)間或者用戶移動(dòng)距離超過了最小值。 更多相關(guān)資訊,請(qǐng)看 Core Location Framework Refere nee。 Core Foun dati on Framework 現(xiàn)在支援在派送佇列(dispatch Core Foun dati on framework(Core Foun

34、 dati on. framework) queues)中進(jìn)行流物件的調(diào)度。 更多相關(guān)資訊,請(qǐng)看 Core Fou ndation Framework Refere nee Core Bluetooth Framework Core Bluetooth framework(CoreBluetooth.framework) 做了如下改進(jìn): 1. 該framework現(xiàn)在可以把 CBCentral和CBPeripheral物件的狀態(tài)資訊進(jìn)行保存,並 且在程式啟動(dòng)的時(shí)候還原一一這個(gè)功能可以支援相關(guān)藍(lán)牙設(shè)備的長期行爲(wèi)。 2. CBCentral和CBPeripheral類現(xiàn)在使用NSUUID物件來存儲(chǔ)

35、唯一標(biāo)示。 3. 現(xiàn)在可以從CBCentralManager中同步的獲取一個(gè) CBPeripheral物件。更多相關(guān)資訊, 請(qǐng)看 Core Bluetooth Framework Referenee 。 AV Foun dati on Framework AV Foundation framework(AVFoundation .framework)做了如下改進(jìn): I. AVAudioSessio n 支持一些新的行爲(wèi):可以選擇音訊輸入的首選項(xiàng),包括來自內(nèi)置麥 克風(fēng)的音訊;支援多通道的輸入和輸出 2. AVVideoCompositi ng和相關(guān)的類支援自訂視頻合成器(video compos

36、itor) 3. AVSpeeehSy nthesizer和相關(guān)的類提供了語音合成功能 4. eapture類新增支援的功能有:查找eamaera支持的格式、支持 60fps錄製、在錄製和預(yù) 覽的時(shí)候,Video的放大(真實(shí)和數(shù)位化)、即時(shí)查找機(jī)器可讀的條碼資料、自動(dòng)對(duì)焦範(fàn)圍的 限制、採集錄製過程中訪問時(shí)鐘。 另外還有很多資訊,筆者就不在這裡一一列出,讀者可以查閱AV Fou ndati on Framework Refere nee 。 Accelerate Framework Aeeelerate framework(Aeeelerate.framework)做了如下改進(jìn): 1. 支援Co

37、re Graphics資料類型的操作 2. 支援灰度圖片:每個(gè)圖元爲(wèi)1、2或4位 3. 可以在不同圖像格式之間進(jìn)行轉(zhuǎn)換 4. 支援 biguad(IIR)操作 更多相關(guān)資訊請(qǐng)看 Accelerate Framework Refere nee Objective-C Objective-C加強(qiáng)了對(duì)模組(module)的支援,這樣可以加快build時(shí)間,以及工程索引的時(shí)間。 用Xcode 5創(chuàng)建的新工程,預(yù)設(shè)支援模組,如果是之前的一個(gè)工程,必須明確的啟動(dòng)模組 的支援:通過修改該工程的En able Modules 設(shè)置。 已經(jīng)過時(shí)的API 時(shí)不時(shí)的,蘋果會(huì)對(duì)一些API增加deprecation 宏,表示在開發(fā)中,相關(guān)的 API不應(yīng)該繼 續(xù)被使用了。當(dāng)然,遇到deprecation時(shí),相關(guān)api並不是立即就過時(shí)了,相反,在一定期 限內(nèi),蘋果會(huì)提供相關(guān)功能的api,進(jìn)行過渡。 作爲(wèi)開發(fā)者來說,儘量避免在代碼中使用過時(shí)的api是非常重要的一一至少,在新寫 的代碼中不要繼續(xù)使用過時(shí)的 api 了,另外,對(duì)於已有的工程中,如果使用了過時(shí)的api, 也儘量對(duì)代碼進(jìn)行更新。 目前,在iOS7中,過時(shí)的api有如下一些: I. Map Kit framework 中的MKOverlayView 和它相關(guān)的子類都已經(jīng)過時(shí)了。並且使

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論