偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

升級(jí)到iOS5后ASIHttpRequest庫(kù)問(wèn)題及解決方法

移動(dòng)開發(fā) iOS
本文為大家介紹了升級(jí)到iOS5后ASIHttpRequest庫(kù)問(wèn)題及解決方法的內(nèi)容,其中作者也一步一步為大家描述了升級(jí)iOS5之后的ASIHttpRequest庫(kù)問(wèn)題及解決方法。

由于正式版的iOS5出來(lái)了,所以我也試著去升級(jí)了。于是下載了最新的Xcode,才1.7G左右,比以往的安裝包要小許多。

升級(jí)Xcode后,打開以前創(chuàng)建的工程, 運(yùn)氣好,一個(gè)錯(cuò)誤都沒(méi)有,程序也能正常跑起來(lái)。由于我程序中用了ASIHttpRequest這個(gè)庫(kù),讓我發(fā)現(xiàn)了一個(gè)小問(wèn)題,就是

ASIAuthenticationDialog這個(gè)內(nèi)置對(duì)話框在網(wǎng)絡(luò)有代理的情況下出現(xiàn),然后無(wú)論點(diǎn)cancle或是login都不能dismiss。在4.3的SDK中完全沒(méi)問(wèn)題,在5.0的SDK中就會(huì)在Console中看到輸出:

Unbalanced calls to begin/end appearance transitions for <ASIAutorotatingViewController:>

很明顯示在sdk5中, 用這個(gè)庫(kù)有問(wèn)題,還有在停止調(diào)式的時(shí)候,程序會(huì)有異常產(chǎn)生。

于是很明顯示是SDK5的變化影響了ASIHttpRequest的正常使用。于是我要fix這個(gè)問(wèn)題,經(jīng)過(guò)我研究發(fā)現(xiàn),dismiss不起作用是由于UIViewController的parentViewController不再返回正確值了,返回的是nil,而在SDK5中被presentingViewController取代了。于是在ASIAuthenticationDialog.m中找到+(void)dismiss這個(gè)方法并修改為:

  1. + (void)dismiss   
  2. {   
  3. #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3    
  4.     UIViewController *theViewController = [sharedDialog presentingViewController];   
  5.     [theViewController dismissModalViewControllerAnimated:YES];   
  6. #else    
  7.     UIViewController *theViewController = [sharedDialog parentViewController];   
  8.     [theViewController dismissModalViewControllerAnimated:YES];   
  9. #endif    
  10. }   

這樣編譯出來(lái)的程序能在ios5設(shè)備上正確運(yùn)行,但是在ios5以下的設(shè)備則會(huì)crash。因?yàn)槭菐?kù),所以要考慮到兼容不同版本,于是進(jìn)一步修改為:

  1. + (void)dismiss   
  2. {   
  3. #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3    
  4.     if ([sharedDialog respondsToSelector:@selector(presentingViewController)])    
  5.     {   
  6.         UIViewController *theViewController = [sharedDialog presentingViewController];   
  7.         [theViewController dismissModalViewControllerAnimated:YES];   
  8.     }   
  9.     else   
  10.     {   
  11.         UIViewController *theViewController = [sharedDialog parentViewController];   
  12.         [theViewController dismissModalViewControllerAnimated:YES];   
  13.     }   
  14. #else    
  15.     UIViewController *theViewController = [sharedDialog parentViewController];   
  16.     [theViewController dismissModalViewControllerAnimated:YES];   
  17. #endif    
  18. }   

還有上面那個(gè)Console的錯(cuò)誤提示,解決方法是,在ASIAuthenticationDialog.m中找到-(void)show這個(gè)方法,并把最后一行代碼

  1. [[self presentingController] presentModalViewController:self animated:YES];   

修改為:

  1. UIViewController *theController = [self presentingController];   
  2. #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_4_3    
  3.     SEL theSelector = NSSelectorFromString(@"presentModalViewController:animated:");   
  4.     NSInvocation *anInvocation = [NSInvocation invocationWithMethodSignature:[[theController class] instanceMethodSignatureForSelector:theSelector]];   
  5.     [anInvocation setSelector:theSelector];   
  6.     [anInvocation setTarget:theController];         
  7.     BOOL               anim = YES;   
  8.     UIViewController   *val = self;   
  9.     [anInvocation setArgument:&val atIndex:2];   
  10.     [anInvocation setArgument:&anim atIndex:3];   
  11.     [anInvocation performSelector:@selector(invoke) withObject:nil afterDelay:1];   
  12. #else          
  13.     [theController presentModalViewController:self animated:YES];   
  14. #endif   

這下就可以正常運(yùn)行了喲, 我的問(wèn)題也解決了。關(guān)于ASIHttpRequest的其它方面,到目前為止還沒(méi)發(fā)現(xiàn)問(wèn)題。

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

2011-10-13 09:40:21

FacebookCredits手機(jī)

2018-11-01 15:26:38

開源軟件安全

2009-07-01 18:14:36

JSP亂碼

2022-04-02 20:27:30

ETS操作系統(tǒng)鴻蒙

2020-08-12 12:10:31

前端開發(fā)技術(shù)

2012-01-18 14:14:29

iOS教程iOS5

2021-06-17 08:07:35

Linux 內(nèi)存站崗

2011-08-24 17:41:16

MySQL死鎖

2011-05-06 17:25:58

硒鼓

2011-08-10 10:00:17

iOS 5升級(jí)

2017-06-14 22:11:57

數(shù)據(jù)庫(kù)MySQL死鎖

2009-08-24 10:37:11

Silverlight

2010-12-27 10:48:10

VirtualboxFreedos

2022-04-06 10:09:17

云服務(wù)云計(jì)算

2021-01-12 11:40:12

SonarQube平臺(tái)數(shù)據(jù)項(xiàng)目授權(quán)

2019-10-11 19:45:28

SparkSQLHiveHadoop

2016-11-14 10:06:04

大數(shù)據(jù)max位圖

2009-03-04 10:38:36

Troubleshoo桌面虛擬化Xendesktop

2025-04-07 07:20:35

SQL慢查詢性能

2010-08-31 13:49:12

CSS
點(diǎn)贊
收藏

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