我正在使用以下代码来审核我的应用。但它不适用于iOS版本8.4 它适用于iOS版本8.3。
if ([SKStoreProductViewController class] != nil) {
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
[storeViewController setDelegate:self];
NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
f.numberStyle = NSNumberFormatterDecimalStyle;
NSNumber *myNumber = [f numberFromString:kAppleID];
NSDictionary *productParams = @{ SKStoreProductParameterITunesItemIdentifier : myNumber };
[storeViewController loadProductWithParameters:productParams completionBlock:^(BOOL result, NSError *error) {
if (result == YES) {
[self presentViewController:storeViewController animated:YES completion:nil];
} else {
// handle the error
NSLog(@"%@",error.description);
}
}];
}
请帮我解决这个问题,也让我知道为什么它不起作用? 非常感谢
答案 0 :(得分:0)
抱歉,我在代码中犯了小错误。 storeViewController loadProductWithParameters:块如果未加载,将返回 NO 。这意味着您已准备好呈现storeViewController。 所以我改变了条件并解决了我的问题
if ([SKStoreProductViewController class] != nil) {
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
[storeViewController setDelegate:self];
NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
f.numberStyle = NSNumberFormatterDecimalStyle;
NSNumber *myNumber = [f numberFromString:kAppleID];
NSDictionary *productParams = @{ SKStoreProductParameterITunesItemIdentifier : myNumber };
[storeViewController loadProductWithParameters:productParams completionBlock:^(BOOL result, NSError *error) {
if (error) {
// handle the error
NSLog(@"%@",error.description);
} else {
[self presentViewController:storeViewController animated:YES completion:nil];
}
}];
}