如何显示“正在加载”执行 REST 请求时无按钮的 AlertView
我正在尝试执行以下操作:
- 显示一个无按钮的 UIAlertView,显示“正在加载”消息
执行 REST 请求,例如
currentPlans = [RestUtils restSynchnonousCall:url 使用方法:@"GET" withBody:nil];
关闭 UIAlertView
return currentPlans
我已经寻找了 dispatch_async
模式,我也查看了这个线程 UIAlertView 开始显示,屏幕变暗,但直到为时已晚才弹出! 没有了解这么多...:(
提前谢谢!
I'm trying to do the following:
- show a buttonless UIAlertView showing a "Loading" message
perform a REST request like
currentPlans = [RestUtils restSynchnonousCall:url usingMethod:@"GET" withBody:nil];
dismissing the UIAlertView
return currentPlans
I've looked for dispatch_async
pattern, I've also looked at this thread UIAlertView starts to show, screen dims, but it doesn't pop up until it's too late! without understanding so much... :(
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
警报视图应该通知用户可以取消或询问简单的事情,例如是/否。对于加载/连接,我建议使用 UIActivityIndicator。请注意,更改标准组件的行为不符合人机界面指南。用户应该能够根据自己的意愿取消警报视图。
Alert view is supposed to inform something that user can cancel or ask for simple things like yes/no. For loading/connecting I suggest to use
UIActivityIndicator
. Please note that changing the behavior of standard components does not comply with the human interface guidelines. User should be able to dismiss an alert view on his/her wish.伊万我认为你需要使用活动指示器来进行“加载”过程。
但是如果您喜欢使用无按钮警报视图,请使用以下代码:
UIAlertView *loadingAlert = [[UIAlertView alloc] initWithTitle:@"正在加载......"
消息:无
代表:无
取消按钮标题:nil
其他按钮标题:nil];
当您的请求完成时...在该委托方法中编写以下代码:
[loadingAlert解雇WithClickedButtonIndex:0动画:是];
此代码会自动终止您的警报视图。
**loadingAlert 必须在 .h 文件内定义。
Ivan I think you need to use Activity Indicator for "Loading" process.
But if you like to use button less alertview then ,use this code:
UIAlertView *loadingAlert = [[UIAlertView alloc] initWithTitle:@"Loading...."
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
When ever your request is done....write this code in that delegate method:
[loadingAlert dismissWithClickedButtonIndex:0 animated:YES];
This code automatically terminate your alertview.
**loadingAlert must be defined inside .h file.