最好的方法還是查看下iOS5
和iOS 4.3版本的函數差異表。提前預防下,對於diffrent
function進行判斷下。由於比較多,就不羅列了。轉載別人寫好的一個。
5.0前後,對應的調用方法變了參數,而且如果用了5.0以後的方法在低版本上無法使用,而用低版本對用的方法,apple已經不提倡,現在有一種解決辦法
- AboutViewController *mAboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
- if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) {
- [self.navigationController presentViewController:mAboutViewController animated:YES completion:nil];
- }else{
- [self.navigationController presentModalViewController:mAboutViewController animated:YES];
- }
- [mAboutViewController release];
- mAboutViewController = nil;
在調用時判斷一下
同理,dismiss時也是類似操作
- if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
- [self dismissViewControllerAnimated:YES completion:nil];
- }else{
- [self dismissModalViewControllerAnimated:YES];
- }
以此類推,以後碰到類似,apple高版本sdk對低版本api不再支持時,可用類似判斷解決高低版本兼容問題。