【问题标题】:show UIAlertView when In app purchase is in progress正在进行应用内购买时显示 UIAlertView
【发布时间】:2010-04-28 04:06:31
【问题描述】:

我添加了一个 UIAlertView,它具有 UIActivityIndi​​catior 作为我的应用程序的子视图。 此 alertView 仅在购买进行时显示。我以这种方式将警报视图放在我的 StoreObserver 中:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
   for (SKPaymentTransaction *transaction in transactions)
    {

       switch (transaction.transactionState)
       {
        case SKPaymentTransactionStatePurchasing:
                [self stillPurchasing]; // this creates an alertView and shows
                break;

        case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];         
                break;

        case SKPaymentTransactionStateFailed:           
               [self failedTransaction:transaction];
               break;

        case SKPaymentTransactionStateRestored:
              [self restoreTransaction:transaction];
              break;

        default:
            break;
       }        
    }

}

- (void) stillPurchasing {

UIAlertView *alert  = [[UIAlertView alloc]initWithTitle: @"In App Purchase" message: @"Processing your purchase..." delegate: nil cancelButtonTitle: nil otherButtonTitles: nil];
self.alertView = alert;
[alert release];

 UIActivityIndicatorView *ind = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
 self.indicator = ind;
 [ind release];
 [self.indicator startAnimating];

 [self.alertView addSubview: self.indicator];
 [self.alertView show];
}

当我点击我的购买按钮时,这个 UIAlertView 与我的 UIActivityIndi​​cator 一起显示。但是当交易完成时,alertView 仍然在视图的顶部,并且指示器是唯一被删除的。我的问题是我应该如何释放 alertView?或者我应该在哪里/何时发布它。

我添加了这些命令以在这些情况下释放我的 alertView 和 Indicator: 案例 SKPaymentTransactionStatePurchased: 案例 SKPaymentTransactionStateFailed: 案例SKPaymentTransactionStateRestored:

[self.indicator stopAnimating];
[self.indicator removeFromSuperview];
[self.alertView release];
[self.indicator release]; 

我只添加了 alertView 以显示购买仍在进行中。任何向用户创建任何反馈的建议都将感谢我..

谢谢

【问题讨论】:

    标签: iphone objective-c uialertview in-app-purchase


    【解决方案1】:

    要删除警报视图,请使用

    [alertView dismissWithClickedButtonIndex:0 animated:YES];
    

    【讨论】:

      猜你喜欢
      • 2020-02-17
      • 1970-01-01
      • 2018-12-26
      • 2023-03-20
      • 2023-02-08
      • 2010-12-17
      • 1970-01-01
      • 1970-01-01
      • 2012-02-23
      相关资源
      最近更新 更多