在Android开发中,我使用ProgressDialog为我提供了一个包含' spinny',一些文本和取消按钮的对话框。除非用户取消对话框,否则我将使用它与CountdownTimer结合在10秒后执行操作。
我已经在iOS中搜索过等效的内容,例如开源SVProgressHUD和MBProgressHUD,但似乎没有人支持添加按钮。
我是否必须自己编写,或者有人知道实现这一目标的简单方法吗?
答案 0 :(得分:8)
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
indicator.center = self.view.center;
[self.view addSubview:indicator];
[indicator bringSubviewToFront:self.view];
[UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE;
如果要显示指标
,请在下面写下代码[indicator startAnimating];
如果要隐藏指标
,请在下面写下代码[indicator stopAnimating];
在How to programmatically add a simple default loading(progress) bar in iphone app
找到UPD :您可以创建没有按钮的警告对话框并手动添加任何自定义元素:
UIAlertView *alert;
...
alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil]; //display without any btns
// alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil]; //to display with cancel btn
[alert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
要解除警报,请执行
[alert dismissWithClickedButtonIndex:0 animated:YES];
有关详情,请访问:http://iosdevelopertips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html