iphone - 在应用内购买正在进行时显示 UIAlertView

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

我在我的应用程序上添加了一个 UIAlertView,它有 UIActivityIndi​​catior 作为 subview 。 此 alertView 仅在购买正在进行时显示。我以这种方式将我的警报 View 放在我的 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 仍然在 View 的顶部并且 Indicator 是唯一被删除的。我的问题是我应该如何释放 alertView?或者我应该在哪里/什么时候发布它。

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

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

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

谢谢

最佳答案

要删除警报 View ,请使用

[alertView dismissWithClickedButtonIndex:0 animated:YES];

关于iphone - 在应用内购买正在进行时显示 UIAlertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2726745/

相关文章:

iphone - Objective C HTML 转义/反转义

ios - 如何以编程方式将 UISegmentedControl 添加到容器 View

uitableview - 如何在 iOS 7 中将 UITableView 添加到 UIAlertView

iphone - UIAlertView 不响应 UIAlertViewDelegate

iphone - 启动画面在 iPhone 设备中不可见

iphone - 一台特定 iOS 设备的新崩溃日志未出现在管理器中

ios - 侧边菜单 revealcontroller 问题与 UITableViewController

ios - 检查运行代码是否为单元测试用例

iphone - NSString 错误

iphone - 高通SDK定制?