Reputation: 17671
I have built a loader screen that displays a loading message and a uiprogresview whilst 4 separate data refresh methods are running - each data refresh method has a completed function - which basically adds .25 to the loader as follows -
self.loaderProgress.progress = self.loaderProgress.progress + 0.25;
I want to apply a method that will re-direct from the loader page to the homepage when all refresh methods are complete (when the loader reaches 1).
I'm not sure how to monitor this figure or trigger this method - can anyone recommend a good solution?
Upvotes: 2
Views: 417
Reputation: 119031
Keep this logic separate from the progress view - i.e. don't query the progress value from the view. The view is for UI, not for state management.
Instead, do something like keep an array of booleans / jobs to be completed, and mark each one off as it completes. When the list is empty, trigger your completion action.
Upvotes: 2
Reputation: 3271
Have you tried as like below?
-(void)method1
{
self.loaderProgress.progress += 0.25;
if (self.loaderProgress.progress == 1)
[self done];
}
-(void)method2
{
self.loaderProgress.progress += 0.25;
if (self.loaderProgress.progress == 1)
[self done];
}
-(void)method3
{
self.loaderProgress.progress += 0.25;
if (self.loaderProgress.progress == 1)
[self done];
}
-(void)method4
{
self.loaderProgress.progress += 0.25;
if (self.loaderProgress.progress == 1)
[self done];
}
-(void)done
{
NSLog(@"Done";
}
Upvotes: 1