应用内购买:视图消失时崩溃
我的应用程序有一个包含 4 个视图控制器的选项卡栏。第三个视图控制器包含“商店应用内购买”。在此控制器中,我使用一个管理应用内购买(产品请求、购买、交易等)的对象,该对象允许我获取并显示价格说明 ecc。
问题是:如果我在请求启动时更改选项卡,应用程序有时会崩溃,但并非总是如此。
我必须在 viewDidDisappear 中取消请求吗? [productsRequest cancel] 此代码崩溃。
My application has a tabbar that contains 4 view controllers. The third view controller contains a "store in-app purchases". In this controller I use an object that manages in-app purchases (product request, purchase, transaction etc...) that allow me to get and show price description ecc.
The problem is: If I change tabs while the request started the app crashes sometimes, but not always.
I've to cancel the request in viewDidDisappear?
[productsRequest cancel] this code crashes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有同样的问题。
要修复它,请取消请求,一切都会好起来的。
当视图控制器消失时:
I have the same issue.
To fix it cancel request and all be fine.
And when disapear viewcontroller:
您的问题可能与应用内购买无关。在代码中的某个位置,您正在向已释放的对象发送消息。运行分析器可以帮助您找到错误,但这次可能没有必要。如果 [productsRequest cancel] 崩溃,则 productsRequest 的保留计数可能太低。
Your problem has probably nothing to do with in-app purchase. Somewhere in your code you're sending a message to an object which has been released. Running the analyzer can help you find the bug, but it may not be necessary this time. If [productsRequest cancel] crashes, then probably productsRequest has too low retain count.
在
viewDidDisappear
时删除TransactionObserver
:如果您从 Inapp 视图控制器返回到另一个视图控制器,则
Remove the
TransactionObserver
while yourviewDidDisappear
:If you go back from the Inapp viewcontroller to another viewcontroller,then