iOS中是否存在与Android ProgressDialog相同的内容

Gar*_*ght 6 android progressdialog ios

在Android开发中,我使用ProgressDialog给我一个带有'spinny'的对话框,一些文本和一个取消按钮.除非用户取消对话框,否则我将使用此结合CountdownTimer在10秒后执行操作.

我已经在iOS中搜索过等效的内容,例如开源SVProgressHUD和MBProgressHUD,但似乎没有人支持添加按钮.

我是否必须自己编写,或者有人知道实现这一目标的简单方法吗?

Vi *_*huk 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;
Run Code Online (Sandbox Code Playgroud)

如果要显示指标,请在下面写下代码

[indicator startAnimating];
Run Code Online (Sandbox Code Playgroud)

如果要隐藏指标,请在下面写下代码

[indicator stopAnimating];
Run Code Online (Sandbox Code Playgroud)

如何以编程方式在iphone应用程序中添加简单的默认加载(进度)栏中找到了

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];
Run Code Online (Sandbox Code Playgroud)

要解雇警报,就这样做

[alert dismissWithClickedButtonIndex:0 animated:YES];
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请访问:http://iosdevelopertips.com/user-interface/uialertview-without-buttons-please-wait-dialog.html