Reputation: 159
What I need to do is present an alert controller with a progressBar. Once the download is complete, I need to transition to a secondary alert controller with a Success! message and an "Ok" button for the user to just exit this setup. I have built the alerts separately and they are working well on their own (well the progress bar is kinda working...) but with this code:
I expect that when the progressBar hits 100% the first alert controller will be dismissed and the next alert will show up, but nothing is happenning This is my code:
-(void)settingUpToolsProgressPopUp {
UIAlertController* progressAlert = [UIAlertController alertControllerWithTitle:@"Setting up tools ..." message:@"This could take a few minutes. Make sure to keep your tools near your mobile device." preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:progressAlert animated:YES completion:^{
//Progress bar setup
UIProgressView *progressView;
progressView = [[UIProgressView alloc]initWithFrame:CGRectMake(8.0, 98.0, progressAlert.view.frame.size.width - 16, 100.0)];
[[progressView layer]setCornerRadius:50];
progressView.trackTintColor = [UIColor whiteColor];
progressView.progressTintColor = [UIColor blueColor];
progressNumerator = 1.0;
progressDenominator = 1.0;
currentProgress = (float)(progressNumerator/progressDenominator);
[progressView setProgress: currentProgress animated:YES];
[progressAlert.view addSubview:progressView];
if(currentProgress > 1.0){
[self settingUpToolsProgressPopUp];
} else if(currentProgress == 1.0){
[self dismissViewControllerAnimated:YES completion:nil];
[self successAlertPopUp];
}
}];
}
p.s. I know that the values are hardcoded right now... but regardless of any values I use the transition doesn't happen. I don't have access to the updating values yet, so I can't use other values right now... but I would expect that if I am using 100% value, then the transition would happen anyway?
Can anyone point me int he right direction? Why isn't this code working for transitioning between these controllers?
Thanks so much!
Upvotes: 1
Views: 124
Reputation: 19698
You need to call successAlertPopUp
method inside dismissViewControllerAnimated
's completion handler:
[self dismissViewControllerAnimated:YES completion:^{
[self successAlertPopUp];
}];
Upvotes: 1