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];
我在如何在 iPhone 应用程序中编程添加简单的默认加载(进度)栏找到了这个内容。
更新:你可以创建一个没有按钮的提示对话框,并手动添加任何自定义元素:
UIAlertView *alert;
...
alert = [[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[alert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
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