以与原来不同的方法关闭警报视图

发布于 2024-11-19 03:23:48 字数 390 浏览 1 评论 0原文

我的应用程序中有一个应用程序内购买,当购买是“购买”或正在进行时,我会出现一个警报视图,显示“正在加载...”。当购买成功、恢复或失败时,我想调用一个释放警报视图的方法。唯一的问题是,我无法尝试用另一种方法释放警报视图,因为它不知道我在谈论什么警报视图,并且会产生错误。现在我不知道这是否是实现这一目标的最佳方法,所以所有想法都值得赞赏。谢谢!

case stateIsPurchasing { //or whatever it's called

    UIAlertView *alert = [[UIAlertView alloc] message and delegate and button stuff here];

    [alert show];
    [alert release];
}

I have an in app purchase in my app and when the purchase is "purchasing", or in progress, I have an alert view come up that says "Loading...". When the purchase was successful, restored, or failed, I'd like to call a method that releases the alert view. The only problem is, I can't try to release the alert view in another method because it will have no idea what alert view I am talking about and will produce an error. Now I have no idea if this is even the best way of trying to accomplish this, so all ideas are appreciated. Thanks!

case stateIsPurchasing { //or whatever it's called

    UIAlertView *alert = [[UIAlertView alloc] message and delegate and button stuff here];

    [alert show];
    [alert release];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猫烠⑼条掵仅有一顆心 2024-11-26 03:23:48

UIAlertView 绝对不是执行此操作的正确控件。

如果您能够显示有限进度,则应使用 UIProgressView 或 UIActivityIndi​​catorView 来显示“微调器”。

The UIAlertView is definitely not the right control to do this.

You should use the UIProgressView if you are able to display finite progression or UIActivityIndicatorView to show the "spinner".

森林很绿却致人迷途 2024-11-26 03:23:48

我不会为此使用警报视图。寻找进度HUD,例如SVProgressHUD,这是一个出色且漂亮的加载视图。

http://cocoacontrols.com/platforms/ios/controls/svprogresshud

SVProgressHUD 的功能是单例,因此您可以从任何类中显示/停止它。

I wouldn't use an alert view for this. Look for a progress HUD, such as SVProgressHUD, an excellent and beautiful loading view.

http://cocoacontrols.com/platforms/ios/controls/svprogresshud

SVProgressHUD functions as a singleton, so you can show/stop it from any class.

爱格式化 2024-11-26 03:23:48

在标头中将 UIAlertView 声明为保留属性,在 dealloc 中合成并释放。使用此指针存储您在该代码片段中创建的警报视图,并在其他方法中使用声明的指针。但在创建警报视图时不要调用[alert release];(除非您喜欢 EXC_BAD_ACCESS 错误!)。哦,如果您要添加应用内购买,请留意 Lodsys...

Declare a UIAlertView in your header as a retained property, synthesized, and released in dealloc. Store the alert view that you create in that code snippet using this pointer, and use the declared pointer in your other method. But don't call [alert release]; when you create the alert view (unless you like EXC_BAD_ACCESS errors!). Oh, if you're adding in-app purchases, watch out for Lodsys...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文