5.0前后,对应的调用方法变了参数,而且如果用了5.0以后的方法在低版本上无法使用,而用低版本对用的方法,apple已经不提倡,会有警告出现
可以采取对“执行事件”捕捉,来间接的完成兼容性
if ([self respondsToSelector:@selector(dismissViewControllerAnimated:animated:completion:)]) { [self dismissViewControllerAnimated:YES completion:nil];//5.0+ } else { [self dismissModalViewControllerAnimated:YES];//4.3- }
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) { [self presentViewController:loginView animated:YES completion:nil];//5.0+ } else { [self presentModalViewController:loginView animated:YES];//4.3- }
参考出路:http://www.2cto.com/kf/201205/133560.html