版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、本文將繼續介紹iOS7中的新特徵,包括:已有Framework的改進、Objective-C和已經過 時的API。 注1 :本文是關於新特徵介紹的最後一篇,隨後的博文,以wwdc2013內容爲主,歡 迎大家關注! 已有Framework 的改進(19個) 下面我們來看看iOS7中有明顯修改的一些 framework。如果要查看完整的新介面,請查看 iOS 7.0 API Diffs。本部分內容看起來可能稍顯枯燥,並且我沒有對其做配圖,所以讀者可 以挑選自己感興趣的部分進行閱讀也不妨。 UIKit Framework UIKit Framework(UIKit.framework) 主要做了如下
2、改進: 1、 所有的使用者介面控制項都做了更新,以與iOS7相適應。 2、UIKit動力可以讓開發者模擬現實世界中的一些效果,例如在動畫中使用重力行爲。 3、Text Kit提供了複雜的文字編輯和顯示功能。 4、UIView類新增加了如下內容: tintColor屬性:可以使用一個 tint color,並對view和它的subview有影響。關於如何使用 tint colors,請看 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可以創建基於關鍵幀的動畫。同樣也可以對view做出改變 任意正在執行的動畫。 5、UIViewController 類新增了如下內容: View
5、controller 之間的切換(transition)可以自訂、驅動式交互(driven interactively),或者完 全根據自己指定的切換方式來替換。 可以通過程式設計的方式指定View con troller 資訊來管理status bar style。當然,在程式的 UIViewC on trollerBasedStatusBarAppeara nee 的幾個用來指定status bar的方法 的status bar和visibility。系統會根據提供的 info.plist檔中,設置 鍵值也是可以的。如下代碼是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類爲運動效果定義了一些基本的行爲一一定義了一個view如何響應
8、基於 設備的運動。 7、 Collection view 支援 UlKit 動力(UlKit Dynamic) 這樣可以將一些行爲物件 (behavior object)應用到 Collection view 的 layout attribute 中,以對 collection view 中的 item 做出相 應的動畫。 8、 UIImage的ImageNamed:方法可以把檢索存儲在asset目錄中的圖片,這就提供了一種 方法一一管理並優化具有多種尺寸和解析度的資源。 9、 UIView和UIScreen提供了一個新的方法:snapshot返回一個view,可以用來顯示 程式的內容。 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 類封裝了從週邊硬體鍵盤接收到的鍵盤事件。這些事件會被分發 (delivered)到程式的回應鏈(responder chain)中以被處理。 11、 UIFontDescriptor 物件使用一個屬性字典來描述字體。通過font descriptor可以與其它 平臺相互交互。 12、UIFont和UIFontDescriptor類支援動態調整字體大小,這樣可以增加程式中文字的易 讀性一一使用者可以控制所有程式的字體大小。 13、 UIActivity類現
12、在支持新的一些 activity類型,包括通過 AirDrop發送資料,給內容到 Safari閱讀清單中,把資料發送到 Flickr、Tencent Weibo 和Vimeo。 14、 UIApplicationDelegate 協定新增了處理後臺獲取資料的操作。 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新增了引導訪問模式(guided-access mode)運行程式自己鎖定,以防止被用 戶修改。這樣的功能主要是為一些機構設計的 ,例如在學校一一學生雖然攜帶了他們的設備 但是需要運行由學校提供的程式。 16、 State還原功能運行保存和還原任意的物件。遵循UlSta
21、teRestoring 協定的物件,當程 式被切換到後臺(background)時,可以把狀態資訊保存起來,之後程式被啟動時,這些狀 態可以被還原。 17、Table view 支援對row或其他元素高度的評估 (estimating),這樣可以提升 Table view 的滾動性能。 更多關於 UlKit framework 的內容,請閱讀 UlKit Framework Referenee Store Kit Framework Store Kit framework(StoreKit.framework)已經遷移到新的訂單系統 (receipt system),這樣 一來,開發者可以在自
22、己的設備上驗證內購(in-app purchase)。同樣也可以在伺服器上進行 程式購買訂單的驗證。 更多關於新訂單系統的使用,請閱讀:Receipt Validation Programmi ng Guide 。 Security Framework Security Framework(Security.framework)現在支持:通過 iCloud,可以把密碼在使用者兩 台設備間進行同步。通過新的keychain屬性(kSecAttrSyncronizable),程式可以爲iCloud 標記它們的keychain item 。 更多相關這個屬性的內容,請看該 framework的標頭檔
23、。關於keychain更多資訊,請看 Keycha in Services Program ming Guide 。 Pass Kit Framework Pass Kit Framework(PassKit.ramework)新增了一些 API針對同時添加多個通行證 (pass),通行證檔的格式也做了相應的調整: 1. 新的key指定通行證的截止日期 2. 可以指定通行證只與特定的藍牙信號相關 3. 利用新的屬性來控制通行證的顯示。可以把通行證進行歸類,並在通行證的背面顯示自訂 的文字內容,以及控制顯示在通行證上的時間值 4. 可以給通行證附帶一些額外的資料資訊,在程式中可以使用這些資料,不
24、過並直接顯示給 使用者 5. 可以指定那些data detector用於通行證的欄位中 更多關於如何在程式中使用Pass Kit的資訊,請閱讀 Passbook Programming Guide。關於 通行證檔的格式,請閱讀Passbook Package Format Refere nee。 Ope nGL ES OpenGL ES做了如下新的擴展: 1. EXT_SRGB 支援sRBG框架緩衝區(framebuffer)操作 2. GL_APPLE_pvrtc_sRGB支援將sRGB紋理資料壓縮爲 PVRTC紋理格式 3. GL_APPLE_draw_instaneed和 GL_APPL
25、E_draw_arrays 可以提升渲染的速度-當程式 在繪製多個相同的實例物件時。 現在可以在vertex shaders 中訪問紋理了;通過 MAX_VERTEX_TEXTURE_IMAGE_UNITS屬性決定你可以訪問紋理的準確數目。 MessageUI Framework 在 MessageUI framework 中,MFMessageComposeViewController 現在可以支援將附件添 加到資訊中。關於新介面內容,可以參看framework標頭檔。關於這個 framework的類, 請閱讀 Message UI Framework Referenee。 Media Pl
26、ayer Framework 在Media Player framework 中,MPVolumeView 類可以判斷用戶選擇的無線路由(wireless route,例如AirPlay和Bluetooth)是否可用。你也可以判斷無線路由當前是否可用。關於新 介面資訊,請參看framework的頭文件。關於Media Player framework涉及到的類,請參 看 Media Player Framework Referenee 。 Map Kit Framework 關於Map Kit framework 相關修改,筆者已經在這裡介紹過:iOS7新特徵匯總02:遊戲、 地圖以及AirD
27、rop 更多相關資訊,請查閱Map Kit Framework Refere nee。 Image I/O Framework Image I/O Framework(ImageIO.framework)現在提供了獲取和設置 image metadata 的介面。 更多相關介面資訊,請看 framework的標頭檔。關於framework類的介紹,請看Image I/O Refere nee Colleetio n 。 iAd Framework iAd framework(iAd.framework) 做了如下修改讓廣告更好的融入到程式中: 在MPMoviePlayerController類
28、中的新方法可以讓你在播放電影之前運行廣告 view controller進行適當的配置在實際內容顯示之前先顯示出廣告內容。 關於新介面請看framework中的標頭檔。關於 framework的介紹,請看 Ad Support Framework Refere nee 。 Game Kit Framework 關於Game Kit Framework(GameKit.framework)的改變,已經在這裡介紹過:iOS7新特徵 匯總02:遊戲、地圖以及 AirDrop 更多相關介紹,請看 Game Kit Framework Refere nee 。 Foun dati on Framewor
29、k Foun dati on framework(F oun dati on. framework)主要做了如下改進: I. NSURLSessi on 類是一個新增的類,主要用於程式在後臺運行時,對網路資源的操 作。這個類替換了 NSURLConnection 和相關delegate ;同樣也替換了 NSURLDownload 和相關delegate 。 2. NSURLComponents 類也是一個新增類一一用來解析URL的構建。這個類在解析URL 的時候支持URI標準(rfc3986/STD66)。 3. NSNetService 和NSNetServiceBrowser 用於在藍牙和
30、Wi-Fi中點對點的查找。 4. NSURLCredential 和NSURLCredentialStorage兩個類可以用來創建同步策略的證書,並 可以從iCloud中移除相關同步策略證書。 5. NSURLCache、NSURLCredentialStorage和 NSHTTPCookieStorage三個類支援存儲請 求的非同步處理。 6. NSCalendar類支持新的日曆類型。 更多關於新的介面,請看 framework中 大標頭檔和 Foundation release notes 。關於該 framework 類的介紹,請看 Foundation Framework Refere
31、nce 。 Core Teleph ony Framework Core Teleph ony framework(CoreTelepho ny.framework)現在可以獲取到設備使用的無線電 資訊:當前的信號強度、cell ID。由運營商開發的相關程式,同樣可以通過預定運營商相關 服務,來對他們的程式進行驗證。 更多相關資訊請看 Core Telepho ny Framework Refere nee。 Core Moti on Framework Core Motion framework(CoreMotion.framework)現在支持 step counting(類似計步器)和運
32、 動的跟蹤。關於 step countingframework通過檢測使用者的運動,然後根據運動資訊 計算出步數(貌似很牛叉的樣子,不知道準確度如何了)。由於運動資訊是由系統檢測的, 所以即使當程式沒有運行的時候,系統也可以持續的收集step資料。通過這樣的功能, framework也能區分出不同的運動類型,例如walking、running或者automobile這對 於導航類程式來說,就可以使用這些資料,直接修改使用者的運動類型。 更多相關資訊,請看 Core Motion Framework Refere nee Core Locati on Framework Core Locatio
33、n framework(CoreLocatio n. framework)可以通過藍牙設備來測距。通過測距可 以確定附近藍牙設備的範圍,並作出相應的反應。例如,在博物館的畫廊裡面,可能有一 些藍牙信號,供參觀者通過相關程式顯示出畫廊的入口和出口。framework還支援推遲位置 的更新的通知,直到特定的時間或者用戶移動距離超過了最小值。 更多相關資訊,請看 Core Location Framework Refere nee。 Core Foun dati on Framework 現在支援在派送佇列(dispatch Core Foun dati on framework(Core Foun
34、 dati on. framework) queues)中進行流物件的調度。 更多相關資訊,請看 Core Fou ndation Framework Refere nee Core Bluetooth Framework Core Bluetooth framework(CoreBluetooth.framework) 做了如下改進: 1. 該framework現在可以把 CBCentral和CBPeripheral物件的狀態資訊進行保存,並 且在程式啟動的時候還原一一這個功能可以支援相關藍牙設備的長期行爲。 2. CBCentral和CBPeripheral類現在使用NSUUID物件來存儲
35、唯一標示。 3. 現在可以從CBCentralManager中同步的獲取一個 CBPeripheral物件。更多相關資訊, 請看 Core Bluetooth Framework Referenee 。 AV Foun dati on Framework AV Foundation framework(AVFoundation .framework)做了如下改進: I. AVAudioSessio n 支持一些新的行爲:可以選擇音訊輸入的首選項,包括來自內置麥 克風的音訊;支援多通道的輸入和輸出 2. AVVideoCompositi ng和相關的類支援自訂視頻合成器(video compos
36、itor) 3. AVSpeeehSy nthesizer和相關的類提供了語音合成功能 4. eapture類新增支援的功能有:查找eamaera支持的格式、支持 60fps錄製、在錄製和預 覽的時候,Video的放大(真實和數位化)、即時查找機器可讀的條碼資料、自動對焦範圍的 限制、採集錄製過程中訪問時鐘。 另外還有很多資訊,筆者就不在這裡一一列出,讀者可以查閱AV Fou ndati on Framework Refere nee 。 Accelerate Framework Aeeelerate framework(Aeeelerate.framework)做了如下改進: 1. 支援Co
37、re Graphics資料類型的操作 2. 支援灰度圖片:每個圖元爲1、2或4位 3. 可以在不同圖像格式之間進行轉換 4. 支援 biguad(IIR)操作 更多相關資訊請看 Accelerate Framework Refere nee Objective-C Objective-C加強了對模組(module)的支援,這樣可以加快build時間,以及工程索引的時間。 用Xcode 5創建的新工程,預設支援模組,如果是之前的一個工程,必須明確的啟動模組 的支援:通過修改該工程的En able Modules 設置。 已經過時的API 時不時的,蘋果會對一些API增加deprecation 宏,表示在開發中,相關的 API不應該繼 續被使用了。當然,遇到deprecation時,相關api並不是立即就過時了,相反,在一定期 限內,蘋果會提供相關功能的api,進行過渡。 作爲開發者來說,儘量避免在代碼中使用過時的api是非常重要的一一至少,在新寫 的代碼中不要繼續使用過時的 api 了,另外,對於已有的工程中,如果使用了過時的api, 也儘量對代碼進行更新。 目前,在iOS7中,過時的api有如下一些: I. Map Kit framework 中的MKOverlayView 和它相關的子類都已經過時了。並且使
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山西消防抽考题库及答案
- 楼房购买合同协议书
- 施工师徒培养协议书
- 2026-2031年中国生态修复市场深度调查与产业竞争格局报告
- 智能电网原理及应用考试题及答案
- 文化墙装修合同范本
- 森叶煤气开户协议书
- 2026-2031全球及中国宠物用品行业发展现状调研及投资前景分析报告(版)
- 基于权重分析表的模糊逻辑算法赋能中央空调系统的深度研究
- 银行社会考试题库及答案
- (高清版)TDT 1056-2019 县级国土资源调查生产成本定额
- 新员工三个月转正的工作总结
- 岗位竞聘目标规划方案
- 不完全性偏瘫教学查房课件
- 济南建筑行业分析
- 组织架构调整与优化计划
- 小学一年级语文生字注音练习-上册
- 2023地下供水管网非开挖修复用塑料管道第1部分:总则
- GB/T 678-2023化学试剂乙醇(无水乙醇)
- 快感体验能力量表(TEPS)
- 燃气锅炉运行记录表
评论
0/150
提交评论