在应用内购买过程中显示UIAlertView [英] show UIAlertView when In app purchase is in progress

查看:85
本文介绍了在应用内购买过程中显示UIAlertView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've added an UIAlertView that has UIActivityIndicatior as a subview on my application. This alertView only show when the purchase is in progress. I've put my alert view in this way in my 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?或者我应该何时/何时发布它。

When I tap my the buy button this UIAlertView shows together with my UIActivityIndicator.. But when the transaction completes the alertView still on the top of the view and the Indicator was the only one that was removed. My question was how should I release the alertView? Or where/When should I release it.

在这些情况下,我添加了这些命令以释放我的alertView和指标:
case SKPaymentTransactionStatePurchased:
case SKPaymentTransactionStateFailed:
case SKPaymentTransactionStateRestored:

I've added these command to release my alertView and Indicator on these cases: case SKPaymentTransactionStatePurchased: case SKPaymentTransactionStateFailed: case SKPaymentTransactionStateRestored:

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

我只添加了alertView以显示购买仍在进行中。任何向用户提供任何反馈的建议都会让我感激不尽。

I've only added the alertView to show that the purchasing was still in progress. Any suggestion to create any feedback to users will be thankful for me..

谢谢

推荐答案

要删除警报视图,请使用

To remove an alert view, use

[alertView dismissWithClickedButtonIndex:0 animated:YES];

这篇关于在应用内购买过程中显示UIAlertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆