下iOS5 和iOS 4.3版本的函数差异  …

来源:互联网 发布:macd背离源码 编辑:程序博客网 时间:2024/05/16 11:22

最好的方法还是查看下iOS5和iOS 4.3版本的函数差异表。提前预防下,对于diffrentfunction进行判断下。由于比较多,就不罗列了。转载别人写好的一个。
5.0前后,对应的调用方法变了参数,而且如果用了5.0以后的方法在低版本上无法使用,而用低版本对用的方法,apple已经不提倡,现在有一种解决办法

[cpp] viewplaincopy
  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时也是类似操作


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


以此类推,以后碰到类似,apple高版本sdk对低版本api不再支持时,可用类似判断解决高低版本兼容问题。