-1

I am trying to create UIProgressViewStyleBar on UIAlertview with JSON loading status info on my app. Now my problem is I cant see UIProgressViewStylebar on iOS 7. Please help me!

My Source:

UIAlertView *alertss = [[UIAlertView alloc] initWithTitle:@"Please Wait..Downloading reports..."    message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] ;
alertss.frame=CGRectMake(50, 50, 280, 40);
UIProgressView *prgView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
prgView.frame = CGRectMake(5, 0, 70, 20);
prgView.hidden=NO;
[alertss addSubview:prgView];
[alertss show];
UILabel *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);
[alertss addSubview:statusLabel];
[alertss show];
MrDoubt
  • 25
  • 6

3 Answers3

0
   UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Running"     message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
   UIProgressView* progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
progressView.frame = CGRectMake(0, 0, 200, 15);
progressView.bounds = CGRectMake(0, 0, 200, 15);
progressView.backgroundColor = [UIColor blackColor];

[progressView setUserInteractionEnabled:NO];
[progressView setTrackTintColor:[UIColor blueColor]];
[progressView setProgressTintColor:[UIColor redColor]];
 [progressView setProgress:0.75f animated:YES];
// you have to set the accessoryView to alertview
[av setValue:progressView forKey:@"accessoryView"];

[av show];
Kamalkumar.E
  • 254
  • 2
  • 11
0

Yeah that is the correct code with that code add this line

 [progressView setProgress:0.75f animated:YES];

before showing your alert. change the progress value depends on your need. or animate it if you want.

enter image description here

Deepakraj Murugesan
  • 1,195
  • 11
  • 30
0

see adding MBprogressHUD is so simple. first download the MBProgressHUD Lib from the GitHub and import in your project as #import "MBProgressHUD.h"

And then simple line to show the progressHUD is as follows :

to show:

[MBProgressHUD showHUDAddedTo:self.view animated:YES]; 

to hide:

[MBProgressHUD hideHUDForView:self.view animated:YES];

for your problem use this code:

  av = [[UIAlertView alloc] initWithTitle:@"Running" message:@"" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];


    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        [av show];
    [MBProgressHUD hideHUDForView:self.view animated:YES];

Here I used the circular loader. if you want to customise it you can use this loader in many forms as you wish.

Deepakraj Murugesan
  • 1,195
  • 11
  • 30