(iPhone/iPad开发)presentViewController相应方法在SDK5.0前后
5.0前后,对应的调用方法变了参数,而且如果用了5.0以后的方法在低版本上无法使用,而用低版本对用的方法,apple已经不提倡,现在有一种解决办法
[cpp]
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时也是类似操作
[cpp]
if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
[self dismissViewControllerAnimated:YES completion:nil];
}else{
[self dismissModalViewControllerAnimated:YES];
}
以此类推,以后碰到类似,apple高版本sdk对低版本api不再支持时,可用类似判断解决高低版本兼容问题。
摘自 安迪·潘 的专栏
相关新闻>>
- 发表评论
-
- 最新评论 更多>>