自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iOS 8 初上手 牛刀小試

移動開發(fā) iOS
本次iOS 8改變了一些細節(jié),包括UIWindow的bounds發(fā)生變化(Window本身發(fā)生了旋轉(zhuǎn))等等,本篇還為大家整理了安裝iOS 8 beta版本注意事項以及QR Code支持的相關(guān)內(nèi)容。

1、UIWindow的bounds發(fā)生變化(Window本身發(fā)生了旋轉(zhuǎn))

iOS 7之前Window的bounds不會隨著方向而變化,但是到了iOS 8以后,隨著設(shè)備方向的旋轉(zhuǎn),window.bounds.size.width和window.bounds.size.height也會相應(yīng)發(fā)生變化。

做個很簡單的測試,代碼如下:

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
  2.     // Override point for customization after application launch. 
  3.      
  4.     [[NSNotificationCenter defaultCenter] addObserver:self 
  5.                                              selector:@selector(orientationChanged:) 
  6.                                                  name:UIDeviceOrientationDidChangeNotification 
  7.                                                object:nil]; 
  8.      
  9.     return YES; 
  10.  
  11. - (void)orientationChanged:(NSNotification*)noti { 
  12.      
  13.     UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; 
  14.     NSString *orientationDes = nil; 
  15.     switch (orientation) { 
  16.         case UIDeviceOrientationLandscapeLeft: 
  17.             orientationDes = @"UIInterfaceOrientationLandscapeRight"
  18.             break
  19.         case UIDeviceOrientationLandscapeRight: 
  20.             orientationDes = @"UIInterfaceOrientationLandscapeLeft"
  21.             break
  22.         case UIDeviceOrientationPortrait: 
  23.             orientationDes = @"UIInterfaceOrientationPortrait"
  24.             break
  25.         case UIDeviceOrientationPortraitUpsideDown: 
  26.             orientationDes = @"UIInterfaceOrientationPortraitUpsideDown"
  27.             break
  28.         default
  29.             orientationDes = @""
  30.             break
  31.     } 
  32.      
  33.     NSLog(@"system ver: %@, \rorientaion: %@, \rwindow bounds: %@"
  34.           [UIDevice currentDevice].systemVersion, 
  35.           orientationDes, 
  36.           NSStringFromCGRect(self.window.bounds)); 

示例代碼很簡單,新建一個工程,然后在delegate中直接添加以上代碼即可。

iOS 8上運行結(jié)果為:

  1. 2014-06-04 09:26:32.016 SviOS8[4143:61114] system ver: 8.0, 
  2. orientaion: UIInterfaceOrientationLandscapeRight, 
  3. window bounds: {{0, 0}, {320, 480}} 
  4. 2014-06-04 09:26:34.788 SviOS8[4143:61114] system ver: 8.0, 
  5. orientaion: UIInterfaceOrientationPortrait, 
  6. window bounds: {{0, 0}, {480, 320}} 
  7. 2014-06-04 09:26:35.791 SviOS8[4143:61114] system ver: 8.0, 
  8. orientaion: UIInterfaceOrientationLandscapeLeft, 
  9. window bounds: {{0, 0}, {320, 480}} 
  10. 2014-06-04 09:26:47.468 SviOS8[4143:61114] system ver: 8.0, 
  11. orientaion: UIInterfaceOrientationPortraitUpsideDown, 
  12. window bounds: {{0, 0}, {480, 320}} 

iOS 7及之前的版本運行結(jié)果為:

  1. 2014-06-04 09:39:00.527 SviOS8[4380:70b] system ver: 7.0.3, 
  2. orientaion: UIInterfaceOrientationLandscapeRight, 
  3. window bounds: {{0, 0}, {320, 480}} 
  4. 2014-06-04 09:39:00.895 SviOS8[4380:70b] system ver: 7.0.3, 
  5. orientaion: UIInterfaceOrientationPortrait, 
  6. window bounds: {{0, 0}, {320, 480}} 
  7. 2014-06-04 09:39:01.225 SviOS8[4380:70b] system ver: 7.0.3, 
  8. orientaion: UIInterfaceOrientationLandscapeLeft, 
  9. window bounds: {{0, 0}, {320, 480}} 
  10. 2014-06-04 09:39:11.004 SviOS8[4380:70b] system ver: 7.0.3, 
  11. orientaion: UIInterfaceOrientationPortraitUpsideDown, 
  12. window bounds: {{0, 0}, {320, 480}} 

通過對比我們可以清晰的看到iOS 8中UIWindow在處理旋轉(zhuǎn)時策略的變更,雖然會因為與之前的版本不同導(dǎo)致現(xiàn)有項目布局存在的bug,但是可以看到iOS 8中的處理方式更加符合我們的預(yù)期,在豎向的時候我們就獲取到width < height, 在橫向則是 width > height,這個符合所見即所得的原則。

題外話,不管是iOS 7還是之前的版本,以及***出的iOS 8,所有的ViewController的bounds都是正確的,所以只需要堅持一個原則“所有布局都是基于VC.view.bounds布局,那么你的App的顯示就一切正常。”

當(dāng)然如果你有任何View不受VC的管理,直接添加到window上,那么就悲劇了,請?zhí)砑哟a去單獨支持。

好消息:所有基于iOS 7 SDK編譯的程序,window的機制還遵循原來的機制,也就是說可以平滑過度到iOS系統(tǒng),所有界面布局一切正常。不得不說蘋果這一點做的真贊,不愧是一家偉大的公司。

2、安裝iOS 8 beta版本注意事項

官方給出的注意事項地址: http://adcdownload.apple.com//wwdc_2014/ios_8_beta_wg4j9a/ios_beta_software_installation_guide.pdf

主要意思是:

1)升級后不可降級,so升級之前還是想清楚

2)做好備份工作,因為畢竟是beta版本,可能有些不穩(wěn)定的地方,可能在升級過程中會丟失數(shù)據(jù)

3)支持設(shè)備:

iPhone 4s, iPhone 5, iPhone 5c, iPhone 5s, iPod touch (5th gen),
iPad 2, iPad with Retina display, iPad Air and iPad mini

4)目前只支持開發(fā)者預(yù)覽

5)反饋問題地址如下: https://developer.apple.com/bug-reporting/

3、QR Code支持

Core Image framework (CoreImage.framework)新增了如下API:

  • 支持自定義imageKernels

  • 增加矩形檢測和圖片中二維碼識別功能

詳細文檔: Core Image Reference Collection.

責(zé)任編輯:閆佳明 來源: cnblogs
相關(guān)推薦

2012-05-03 10:24:02

ApacheMINAJava

2021-03-08 08:21:19

詞云數(shù)據(jù)可視化大數(shù)據(jù)

2010-03-05 17:25:07

sharepoint

2011-11-30 16:02:13

筆記本評測

2017-04-11 20:49:02

機器學(xué)習(xí)大數(shù)據(jù)數(shù)據(jù)分析

2014-12-16 15:10:32

APC BR1000G后備式UPS電源

2021-01-08 09:07:19

Scrapy框架爬蟲

2017-05-04 21:15:30

Android分辨率

2012-02-24 10:48:56

語盒開源

2021-05-20 07:56:35

Bean容器Spring

2023-10-07 08:59:02

2022-07-04 23:24:28

sql優(yōu)化監(jiān)控

2018-01-01 23:02:56

2011-09-15 11:04:22

Windows 8平板

2023-04-20 17:41:38

開源清華

2011-10-13 10:08:51

iOS 5iOS

2022-06-08 21:13:49

iOSiOS 16

2011-04-26 09:13:15

webservice

2014-06-06 14:25:03

iOS 8SwiftWWDC2014
點贊
收藏

51CTO技術(shù)棧公眾號