0

I have a UIButton that trigger the IAP process. There is some time (2/3s or more if internet connection is bad) before an alert view is displayed (either asking for id and password, or the confirmation one). So one may click several times, thinking that the button is not working. And then you get as much alert view in a row as times you clicked and they are shown even if I quit the app and I'm on another meanwhile. That's pretty annoying.

My solution so far is to set a boolean as property of the UIviewcontroller. If it's false, click does nothing, else click trigger payment process. I set it to false on first click and in viewwillappear i get it back to true. The problem is that to be able to click the button again you must leave view and come back to it. That's not cool...

So here is what I'm looking for ideally : a function that is triggered as soon as any alert view of any kind is shown or dismissed. Show is better because i could use that to stop an eventual activity indicator I'd like to add too.

Thank you for you ideas.

4

1 回答 1

0

不要基于正在显示的警报视图(无论如何你不能)。相反,当按下按钮时,禁用或隐藏它(并显示您的活动指示器)。当您开始购买时,将您的控制器添加为委托人。当您收到告诉您购买完成/失败的回调时,使用委托方法更新 UI 以启用/显示按钮(或将其全部删除,如果更合适的话)。

于 2013-10-15T17:39:07.423 回答