问题描述
stretchableImageWithLeftCapWidth:topCapHeight:用于调整大小图像的方法(iOS低于5.0),但在iOS 5中该方法已被弃用,iOS 5有新的resizableImageWithCapInsets:
支持在低于5且低于5的iOS中调整大小图像的最佳方法是什么?
我知道的第一件事就是使用responseToSelector方法。但也许有人知道其他例子。
stretchableImageWithLeftCapWidth:topCapHeight: is method that used for resize image (iOS lower than 5.0), but in iOS 5 that method is deprecated and iOS 5 have the new one resizableImageWithCapInsets:
What the best way to support resize images in iOS lower than 5 and greeter than 5?First thing that I know is to use responseToSelector method. But perhaps somebody know an other examples.
推荐答案
支持版本通常很简单,唯一要避免的陷阱是使用条件建立以决定支持哪些功能,因为这需要您为每个版本使用特定的二进制文件。
It is generally pretty simple to support versions, the only pitfall to avoid is using conditional building to decide what features to support as that would require you to use a specific binary for each version.
我会使用这样的东西:
NSString* featureVersion = @"5.0";
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[object someIOS5SpecificMethod];
}
else
{
[object alternateMethod];
}
要使用特定于版本的类,您可以使用类似于以下内容的类:
To use version specific classes you could always use something similar to:
Class class = NSClassFromString(@"iOS5OnlyClass");
if (class)
{
id object = [[class alloc] init];
}
这篇关于支持以前iOS版本和弃用方法功能的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!