【问题标题】:UIActivityIndicatorView not displaying in UIAlertView - iOS7 [duplicate]UIActivityIndi​​catorView 未显示在 UIAlertView - iOS7 [重复]
【发布时间】:2013-09-24 11:59:54
【问题描述】:

加载时我需要UIActivityIndicatorView in UIAlertView。但是,当我在 iOS 7 中使用 UIActivityIndicatorView not displaying in UIAlertView - iOS7 添加它时,UIActivityIndicatorView 没有显示。这在 iOS 6 和最低版本中运行良好。下面是我的代码。

有什么解决办法吗? .谢谢。

UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:@"\n\n\n\nloading.." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alertView show];

UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.frame= CGRectMake(50, 10, 37, 37);
activityIndicator.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;

[alertView addSubview:activityIndicator];

[activityIndicator startAnimating];

【问题讨论】:

    标签: objective-c ios6 ios7 uialertview uiactivityindicatorview


    【解决方案1】:

    Apple 弃用了addSubview 方法以防UIAlertView。所以你不能再向 AlertView 添加任何子视图,例如:活动指示器或一些进度条。

    在这里您可以查看我的问题,人们在哪里共享支持添加控件的自定义警报

    UIAlertView addSubview in iOS7

    【讨论】:

      【解决方案2】:

      您不能使用UIAlertView 进行自定义

      阅读此documentation

      最好的方法是创建自定义 UIView,其外观/功能类似于 UIAlertView,并在此视图上添加您的活动指示器。

      【讨论】:

      • 如果我们创建一个 UIView 弹出框并且键盘出现在那个 UIView 上
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多