警报视图在iOS7显示白色矩形
问题说明
以下代码在iOS 5到6.1中运行良好。我甚至在应用程序中存储了该代码:
The following code works perfectly from iOS 5 to 6.1. I even have applications in store with that code:
-(void)showActivityIndicator
{
if(!mLoadingView) //
{
mLoadingView = [[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
mLoadingView.tag = kAlertViewTag;
}
[mLoadingView show];
}
- (void)willPresentAlertView:(UIAlertView *)alertView
{
if (alertView.tag == kAlertViewTag)
{
UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
actInd.frame = CGRectMake(128.0f, 45.0f, 25.0f, 25.0f);
[alertView addSubview:actInd];
[actInd startAnimating];
UILabel *l = [[UILabel alloc]init];
l.text = NSLocalizedString(@"PRODUCT_PURCHASE_INDICATOR_TITLE", @"Please wait...");
l.font = [UIFont fontWithName:@"Helvetica" size:16];
float strWidth = [l.text sizeWithFont:l.font].width;
float frameWidth = alertView.frame.size.width;
l.frame = CGRectMake((frameWidth - strWidth)/2, -25, 210, 100);
l.textColor = [UIColor whiteColor];
l.shadowColor = [UIColor blackColor];
l.shadowOffset = CGSizeMake(1.0, 1.0);
l.backgroundColor = [UIColor clearColor];
[alertView addSubview:l];
}
}
它将显示没有按钮和活动指示器的警报视图和标签。但是在iOS7中我只能看到白色的圆角矩形,没有活动指示。
It will show alert view without buttons and with activity indicator and label. However in iOS7 I can see only white rounded rectangle, no activity indicator.
从iOS 5到7,我能做些什么工作?
What can I do to have this work from iOS 5 to 7?
更新:
为了更具描述性,我正在添加屏幕截图。以下是iOS 5到6.1截图。在那里工作正常。
To be more descriptive I'm adding screenshots. The following is iOS 5 to 6.1 screenshot. Works fine there.
以下是iOS7。正如您所看到的,即使尺寸更小。看起来它没有完全初始化或者什么。
The following is iOS7. As you can see even the size is smaller. Looks like it's not fully initialized or something.
正确答案
现在 addSubview
在iOS7中的 UIAlertView
中不可用
now addSubview
is not available in UIAlertView
in iOS7
UIAlertView
class旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改
The UIAlertView
class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified
作为替代方法,您可以使用 SVProgressHUD
。
As an alternative you can use SVProgressHUD
.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhbbjfee
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
检查邮件是否发送成功
it1352 07-25 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22