(iPhone/iPad開發)presentViewController相應方法在SDK5.0...

5.0先後,對應的調用方法變了參數,並且若是用了5.0之後的方法在低版本上沒法使用,而用低版本對用的方法,apple已經不提倡,如今有一種解決辦法 api

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; app

在調用時判斷一下 spa

同理,dismiss時也是相似操做 it

if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
            [self dismissViewControllerAnimated:YES completion:nil];
        }else{
            [self dismissModalViewControllerAnimated:YES];
        }
以此類推,之後碰到相似,apple高版本sdk對低版本api再也不支持時,可用相似判斷解決高低版本兼容問題。
相關文章
相關標籤/搜索