下iOS5 和iOS 4.3版本的函數差異  …

最好的方法還是查看下iOS5 和iOS 4.3版本的函數差異表。提前預防下,對於diffrent function進行判斷下。由於比較多,就不羅列了。轉載別人寫好的一個。
5.0前後,對應的調用方法變了參數,而且如果用了5.0以後的方法在低版本上無法使用,而用低版本對用的方法,apple已經不提倡,現在有一種解決辦法

  1. AboutViewController *mAboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];  
  2.   
  3.         if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) {  
  4.             [self.navigationController presentViewController:mAboutViewController animated:YES completion:nil];  
  5.         }else{  
  6.             [self.navigationController presentModalViewController:mAboutViewController animated:YES];  
  7.         }  
  8.         [mAboutViewController release];  
  9.         mAboutViewController = nil;  

在調用時判斷一下


同理,dismiss時也是類似操作


  1. if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {  
  2.             [self dismissViewControllerAnimated:YES completion:nil];  
  3.         }else{  
  4.             [self dismissModalViewControllerAnimated:YES];  
  5.         }  


以此類推,以後碰到類似,apple高版本sdk對低版本api不再支持時,可用類似判斷解決高低版本兼容問題。


發佈了100 篇原創文章 · 獲贊 2 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章