繁体   English   中英

在ios7中未显示progressview

[英]progressview is not getting displayed in ios7

我正在通过将它作为子视图添加到alertview中来显示一个progressview和一个标签,并且在IOS6上运行良好,我在IOS7上测试了相同的内容,并且未显示progressview和label。 下面是我的代码。 要使其在ios7上工作,需要做哪些更改?

 alert = [[UIAlertView alloc] initWithTitle:@"Please Wait..Downloading reports..."    message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] ;
alert.frame=CGRectMake(50, 50, 280, 40);
prgView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
prgView.frame = CGRectMake(10, 60, 265, 20);
prgView.hidden=NO;
[alert addSubview:prgView];
statusLabel = [[UILabel alloc] init];
statusLabel.backgroundColor = [UIColor clearColor];
statusLabel.textColor = [UIColor whiteColor];
statusLabel.font = [UIFont fontWithName:@"AmericanTypewriter-Condensed" size:18.0];
statusLabel.frame = CGRectMake(120, 80, 80, 20);
[alert addSubview:statusLabel];
[alert show];

尝试使用showInView而不是addSubview

[alert showInView:self.view];

与OP稍有不同,为那些通过搜索找到它的人添加了。 在我的情况下,UIProgressBar被添加到UIView而不指定Y偏移量。 在iOS6下,它显示在导航栏下,但在iOS7下,进度栏在导航栏后面。 我通过将进度条框架Y设置为导航栏的Y +高度来解决了这个问题,如下所示:

CGRect navframe = [[self.navigationController navigationBar] frame];
CGFloat yloc = (navframe.size.height + navframe.origin.y);

UIProgressView *progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar ];
CGRect pbFrame = progressBar.frame;
CGRect vFrame = self.view.frame;
pbFrame.size.width = vFrame.size.width;
pbFrame.origin.y = yloc;
progressBar.frame = pbFrame;

[self.view addSubview:progressBar];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM