小编Bot*_*ock的帖子

StoreKit委托方法未被调用

我有个问题.永远不会调用SKProductsRequest委托方法.这是先前被问到的,但它没有答案.StoreKit委托函数未被调用

我不是母语为英语的人,有时听起来很滑稽:P :(

我想在我的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);

}
Run Code Online (Sandbox Code Playgroud)

我在我的app委托中创建了一个实例

@interface VRAppDelegate
@property (strong, nonatomic) VRStoreController *store;
@end
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我在appDidFinishLaunching:方法中运行[store requestProducts]时,此代码可以正常工作.

- (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;
}
Run Code Online (Sandbox Code Playgroud)

但是当我在设置tableView:didSelectRowAtIndexPath中运行代码时:委托方法永远不会被调用. …

objective-c storekit ios

4
推荐指数
2
解决办法
4121
查看次数

标签 统计

ios ×1

objective-c ×1

storekit ×1