简体   繁体   中英

IOS - UiProgressView - Trigger event at 100%

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?

Keep this logic separate from the progress view - ie 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.

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";
}

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