StretchableImageWithLeftCapWidth:topCapHeight:是用于调整图像大小(iOS低于5.0)的方法,但是在iOS 5中,该方法已弃用,iOS 5具有新的resizableImageWithCapInsets:
在iOS中支持小于5且小于5的尺寸调整图像大小的最佳方法是什么?
我知道的第一件事是使用responseToSelector方法。但是也许有人知道另一个例子。

最佳答案

支持版本通常非常简单,唯一要避免的陷阱是使用条件构建来确定要支持的功能,因为这将要求您为每个版本使用特定的二进制文件。

我会用这样的东西:

NSString* featureVersion = @"5.0";
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
     [object someIOS5SpecificMethod];
}
else
{
     [object alternateMethod];
}

要使用特定于版本的类,您可以始终使用类似于以下内容的类:
Class class = NSClassFromString(@"iOS5OnlyClass");
if (class)
{
   id object = [[class alloc] init];
}

10-07 19:30
查看更多