我遇到問題。 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