应用商店产品视图中,不适用于IOS 5,如何测试?

应用商店产品视图中,不适用于IOS 5,如何测试?,ios,objective-c,cocoa-touch,methods,Ios,Objective C,Cocoa Touch,Methods,我正在为应用程序内appstore产品视图使用新API。我知道它只能在IOS 6和更高版本上运行,但是,我的应用程序是针对IOS 5和更高版本的。现在,当你点击带你去商店的按钮时,这个应用程序会变成柠檬色,冻结在你身上 SKStoreProductViewController 如何测试此设备是否能够执行此功能?或者如果这是ios 6或更高版本 我正在寻找类似于“应用程序内邮件”的东西,它有一个名为CanSendMail的方法,是否有这样的方法用于SKStore 此外 我将框架弱链接为选项 UPA

我正在为应用程序内appstore产品视图使用新API。我知道它只能在IOS 6和更高版本上运行,但是,我的应用程序是针对IOS 5和更高版本的。现在,当你点击带你去商店的按钮时,这个应用程序会变成柠檬色,冻结在你身上

SKStoreProductViewController

如何测试此设备是否能够执行此功能?或者如果这是ios 6或更高版本

我正在寻找类似于“应用程序内邮件”的东西,它有一个名为
CanSendMail
的方法,是否有这样的方法用于
SKStore

此外

我将框架弱链接为
选项

UPADTE

我试着用这个,但还是不起作用!!没有任何日志:(


测试类在运行时是否可用的一般方法是使用。因此,您可以执行以下操作:

Class cls = NSClassFromString(@"SKStoreProductViewController");
if (cls)
{
    // The device is iOS 6.0 or higher, so it's safe to use this class
    SKStoreProductViewController *viewController = [[cls alloc] init];
    ...
}
else
{
    // The device is pre-iOS 6.0; show an error message or have some other
    // reasonable fallback behavior
}

如果您使用的框架在您目标的最低版本的iOS中不可用,那么您还必须确保您该框架的薄弱环节。正如@rmaddy所指出的,您应该查看完整的血淋淋的详细信息。

我发现这最有效:

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

if (SYSTEM_VERSION_LESS_THAN(@"6.0")) {

// iOS Version 5.1 and older    

}

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {

// iOS Version 6.0 and later    

}
将门店产品视图代码复制到6.0以上版本,将回退代码复制到5.1及以上版本


我从这里学到了这一点。祝你好运!!

在过去,你仍然会因为调用
alloc
中引用类名而崩溃。这仍然是一个问题吗?我总是在
class
对象上调用
alloc
NSClassFromString
@rmaddy获得的
class
对象:我想你是对的,我在这个问题上有点模糊e详细信息并从内存中重建了我的示例。我应该将其放在哪种方法下?@AdamRosenfield,这是真的!当我使用与设置商店产品视图相同的方法时,我遇到了一个崩溃!您可以查看以获取正确执行运行时检查(如此)的完整详细信息。@rmaddy,因此我知道没有特殊的方法可以r这个类,比如
MailComposer
中的
CanSendMail
?不,没有。我从来没有暗示过有。即使有,它在iOS 5.x下也没有用,因为这个类直到6.0才被添加。我提供的链接将帮助您正确地使用在每个iOS版本中都不存在的类、方法和框架t您的应用程序不支持。请参阅Adam的答案,以了解对
SKStoreProductViewController
类的正确检查。
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

if (SYSTEM_VERSION_LESS_THAN(@"6.0")) {

// iOS Version 5.1 and older    

}

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {

// iOS Version 6.0 and later    

}