当我的实现SKPaymentTransactionObserver的对象被调用时,我似乎无法让我的UI更新。SKPaymentTransactionObserver方法的UI更新
具体来说,我有一个(UILabel *)debugLabel在我的用户界面(所有通过IB连接)。我有我的执行观察者协议:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
NSLog(@"paymentQueue: current thread is main thread: %@", [[NSThread currentThread] isMainThread][email protected]"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应该更新。 (对吧?)
什么给?它一定会错过简单的东西?
感谢您的任何见解,指针等