iOS StoreKit项目不填充tableview

时间:2013-04-21 00:03:55

标签: ios uitableview storekit

我正在创建一个带有商店的iOS应用程序,用户可以在该商店购买应用程序的升级。我试图用itunes connect的产品填充UITableView。在下面的代码中,我的iOS应用程序获取产品(它在日志中正确执行),然后它发布通知以更新tableview(被调用)。由于某种原因,项目日志中的值不在表中。在测试中,我将NSArray设置为一些静态值,以确保表视图能够正常工作。我实施商店错了吗?或更新不正确?

- (void)viewDidLoad
{
    [super viewDidLoad];

    _tableview = [[UITableView alloc] init];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadData:) name:kInAppPurchaseManagerProductsFetchedNotification object:nil];
    [self requestProUpgradeProductData];


}
-(void)viewWillDisappear:(BOOL)animated{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:kInAppPurchaseManagerProductsFetchedNotification object:nil];
}
- (void)requestProUpgradeProductData
{
    NSSet * productIdentifiers = [NSSet setWithObjects:
                                  @"0xxxxxxxxxxxxxxxxx",
                                  @"1xxxxxxxxxxxxxxxxx",
                                  @"2xxxxxxxxxxxxxxxxx",
                                  nil];
    productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
    productsRequest.delegate = self;
    [productsRequest start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    _products = [[NSArray alloc]initWithArray:response.products];
    for (SKProduct * product in _products) {
        NSLog(@"%@",product.localizedTitle);
    }
    [[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}
-(void)reloadData:(NSNotification *)pNotification{
    [_tableview reloadData];
}

0 个答案:

没有答案