调用实现SKPaymentTransactionObserver的对象时,我似乎无法更新UI。
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
NSLog(@"paymentQueue: current thread is main thread: %@", [[NSThread currentThread] isMainThread]?@"YES":@"NO");
for (SKPaymentTransaction *transaction in transactions) {
if (transaction.transactionState == SKPaymentTransactionStatePurchased) {
// if the store is still being viewed, update appropriately
if(spViewController.storeViewController) {
[spViewController.storeViewController transactionComplete:transaction];
}
}
// other transactionStates omitted for brevity
}
}
这个
[spViewController.storeViewController transactionComplete:transaction]
执行,但UILabel不显示指定的文本。
- (void) transactionComplete:(SKPaymentTransaction *) transaction {
NSLog(@"CBTSVC transactionComplete");
debugLabel.text = @"CBTSVC transactionComplete";
// other UI updates omitted for brevity
}
当代码执行时,NSLog会将字符串转储到控制台,但UILabel不会更新。我已经确认了对SKPaymentTransactionObserver的回调发生在主线程上,因此UI应该正在更新。(对吗?)
有什么好处?一定少了些简单的东西?
谢谢你的意见和指点。