我正在开发一个 iOS 应用程序。它目前仅适用于 iOS 4,因为我多次使用以下方法:“UIGraphicsBeginImageContextWithOptions”。此方法仅在 iOS 4 中可用,因此我的应用程序当前在 iPhone OS 3 上崩溃/无法运行。除了这种方法之外,没有理由让该应用程序在 iPhone OS 3 上无法运行。我该如何检查看看这个方法是否可用?我尝试了以下但没有成功:
if([self respondsToSelector:@selector(UIGraphicsBeginImageContextWithOptions)]) {
UIGraphicsBeginImageContextWithOptions(targetSize, NO, 0.0); // this will crop
}
else
{
UIGraphicsBeginImageContext(targetSize);
}
我只尝试过这样的变体:
if([self respondsToSelector:@selector(UIGraphicsBeginImageContextWithOptions:size:opaque:scale:)])
和
if([self respondsToSelector:@selector(UIGraphicsBeginImageContextWithOptions:)])
没有成功。任何帮助,将不胜感激。