以与原来不同的方法关闭警报视图
我的应用程序中有一个应用程序内购买,当购买是“购买”或正在进行时,我会出现一个警报视图,显示“正在加载...”。当购买成功、恢复或失败时,我想调用一个释放警报视图的方法。唯一的问题是,我无法尝试用另一种方法释放警报视图,因为它不知道我在谈论什么警报视图,并且会产生错误。现在我不知道这是否是实现这一目标的最佳方法,所以所有想法都值得赞赏。谢谢!
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UIAlertView 绝对不是执行此操作的正确控件。
如果您能够显示有限进度,则应使用 UIProgressView 或 UIActivityIndicatorView 来显示“微调器”。
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".
我不会为此使用警报视图。寻找进度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.
在标头中将
UIAlertView
声明为保留属性,在dealloc
中合成并释放。使用此指针存储您在该代码片段中创建的警报视图,并在其他方法中使用声明的指针。但在创建警报视图时不要调用[alert release];
(除非您喜欢 EXC_BAD_ACCESS 错误!)。哦,如果您要添加应用内购买,请留意 Lodsys...Declare a
UIAlertView
in your header as a retained property, synthesized, and released indealloc
. 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...