进度视图未在ios7中显示

时间:2013-10-04 12:43:55

标签: ios ios7 uiprogressview

我通过将其作为子视图添加到警报视图来显示进度视图和标签,并且在IOS6上工作正常,我在IOS7上测试了同样的事情,并且没有显示progressview和标签。下面是我的代码。需要做些什么改变才能使它在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];

2 个答案:

答案 0 :(得分:1)

尝试使用showInView代替addSubview

[alert showInView:self.view];

答案 1 :(得分:0)

与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];