我遇到问题。 SKProductsRequest委托方法永远不会被调用。这是以前问的,但它没有答案。 StoreKit delegate functions are not getting calledStoreKit代理方法未被调用
我不是英语为母语,我也许听起来滑稽次:第:(
我要实现我的iOS应用StoreKit我做了一个类来处理所有的StoreKit通信这是验证码:
@implementation VRStoreController
- (void) requestProducts
{
SKProductsRequest *request= [[SKProductsRequest alloc]
initWithProductIdentifiers:
[NSSet setWithObject: @"myProductID"]];
request.delegate = self;
[request start];
[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:YES];
}
- (void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSLog(@"F7U12");
[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
NSArray *myProducts = response.products;
NSLog(@"%@", myProducts);
}
我在我的应用程序委托创建一个实例
@interface VRAppDelegate
@property (strong, nonatomic) VRStoreController *store;
@end
奇怪的是,这个代码工作正常,当我在我的APPD运行[店requestProducts] idFinishLaunching:方法。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//app initialization...
self.store = [[VRStoreController alloc]init];
[store requestProducts]; //This works ok, delegate method gets called.
return YES;
}
但是当我在设置运行代码的tableView:didSelectRowAtIndexPath方法:委托方法不会被调用。
//VRAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//app initialization...
self.store = [[VRStoreController alloc]init];//initialize store
return YES;
}
//VRSettingsViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
//case 0, 1...
case 2:
{
VRStoreController *store = ((VRAppDelegate *)[UIApplication sharedApplication].delegate).store;
[store requestProducts]; //calls SKProductRequest start, but never calls delegate method.
NSLog(@"GO PRO");
}
default:
break;
}
}
我不知道我在做什么坏事。尝试几乎所有的东西,没有错误,没有崩溃,但委托永远不会被调用。任何帮助将非常感激。
非常感谢!
恭喜修理!如果可以,请确保将答案标记为“已接受”,以便其他人会注意到您的问题已得到解决,并能够从您的解决方案中学习。干杯〜 – 2012-03-30 14:27:24
我同意,它不应该被保留,只是更多不必要的代码行。 – spybart 2014-05-08 21:11:12
最后它能正常工作。在添加上面的技巧后,它没有工作,然后我也综合了我的inApp类(这是在另一个类中调用)。所有的作品,没有更多的崩溃和代表正在呼叫:) – Muzammil 2014-05-22 19:30:39