简体   繁体   中英

progressview is not getting displayed in ios7

I am displaying a progressview and a label by adding it as a subviews to an alertview, and that was working fine with IOS6, i tested same thing on IOS7, and progressview and label are not getting displayed. below is my code. what changes need to be done to make it work on 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];

slightly different than the OP, added for those who find this by searching. in my case the UIProgressBar was added to a UIView without specifying the Y offset. Under iOS6 this displayed under the navigation bar, but under iOS7 the progress bar is behind the navigation bar. I solved the problem by setting the progress bar frame Y to be the Y + height of the navigation bar as in:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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