1

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];
Shekhar Gupta
  • 6,206
  • 3
  • 30
  • 50
RockandRoll
  • 409
  • 5
  • 23
  • 1
    you are not allowed to add any subview to the `UIAlertView` or `UIActonSheet` from iOS7, you should find another way. – holex Oct 04 '13 at 12:46
  • oh..ok.. thanks holex.. do u know whats the reason behind that? – RockandRoll Oct 04 '13 at 12:53
  • I think it is related to the user privacy, because many applications did the trick: without the user's definite wish, they chosen this or that option automatically (not only in the UIAlertView), which is not really fair behaviour e.g. in case of IAP; so I guess they like to limit the access to the system related controls, and that would be the beginning of the procedure. – holex Oct 04 '13 at 18:36
  • @RockandRoll did you ever find a solution to this problem? – Patrick Goley Dec 03 '13 at 20:00

2 Answers2

1

Try using showInView instead of addSubview

[alert showInView:self.view];
Shekhar Gupta
  • 6,206
  • 3
  • 30
  • 50
0

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];
robm
  • 1,303
  • 1
  • 16
  • 24