我添加了一个 UIAlertView,它具有 UIActivityIndicatior 作为我的应用程序的子视图。此 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 与我的 UIActivityIndicator 一起显示。但是当交易完成时,alertView 仍然在视图的顶部,并且指示器是唯一被删除的。我的问题是我应该如何释放 alertView?或者我应该在哪里/何时发布它。
我添加了这些命令以在这些情况下发布我的 alertView 和 Indicator: case SKPaymentTransactionStatePurchased: case SKPaymentTransactionStateFailed: case SKPaymentTransactionStateRestored:
[self.indicator stopAnimating];
[self.indicator removeFromSuperview];
[self.alertView release];
[self.indicator release];
我只添加了 alertView 以显示购买仍在进行中。任何向用户创建任何反馈的建议都将感谢我..
谢谢