Ios 将UIActivityIndicatorView添加到UIAlertView
我想在消息中添加一个活动指示器,uiAlert消息,我基本上尝试了internet上的所有内容,但没有任何效果,我将只使用uialertview,以下是我的代码Ios 将UIActivityIndicatorView添加到UIAlertView,ios,objective-c,uialertview,uiactivityindicatorview,Ios,Objective C,Uialertview,Uiactivityindicatorview,我想在消息中添加一个活动指示器,uiAlert消息,我基本上尝试了internet上的所有内容,但没有任何效果,我将只使用uialertview,以下是我的代码 UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:@"Please Wait...." message:@"\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles: nil]; UIActivityIn
UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:@"Please Wait...." message:@"\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(125, 50, 30, 30)];
progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
progress.color = [UIColor blackColor];
[waitAlert addSubview: progress];
[progress startAnimating];
[waitAlert show];
这就是我最终得到的我错过了什么 尝试使用
UIAlertViewDelegate
方法添加您的UIActivityIndicator
:
- (void)didPresentAlertView:(UIAlertView *)alertView
{
UIActivityIndicatorView *progress = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
progress.frame = CGRectMake(125, 50, 30, 30);
[progress startAnimating];
[alertView addSubview:progress];
}
在iOS 7中,您无法在UIAlertView上添加任何子视图,这在iOS 6.1之前是可能的。因此,MBProgressHud是实现这一点的最佳且简单的解决方案为什么不使用…它是一个非常整洁的加载程序库,使用起来非常简单…使用
iOS7
,您无法将子视图添加到UIAlertView
。您必须创建自己的AlertView,或者使用CocoaControls/GitHub上提供的AlertView。请参阅的可能副本:您可以在UIAlertView上添加子视图,但不会显示子视图。您可以检查其子视图计数属性。您可以在UIAlertView上添加子视图,但不显示子视图。您可以检查它的子视图计数属性。