How can I display a progress bar to wait before launching the application on the iPhone

It takes a long time to launch the application that I write on the iPhone. I hope to display a progress bar to indicate the percentage of the run run. Can someone help me? I am new to iOS development.

0
source share
2 answers

You can not. The application must be running before you can display any dynamic content. After loading the first ViewController, you can, of course, display a progress bar and load. Prior to this, you can only show the static image Default.png and Default@2x.png. If you delay intensive loading after completing your method -[ViewController viewDidLoad], you can display any graphical interface when doing heavy work.

Edit: In this example, the new thread in your DidLoad view will be disconnected and do the hard work (in this case, sleep for 1 second) and update UIProgressViewand record the progress when it sleeps 10 times, increasing the execution time to 0.1 each time.

- (void)viewDidLoad
{
 // .....
   [NSThread detachNewThreadSelector:@selector(workerBee) toTarget:self withObject:nil];
}

- (void)workerBee
{
    NSAutoreleasePool* workerPool = [[NSAutoreleasePool alloc] init];

    // Put your image loading between this line and [workerpool release]

    for (float i = 0; i<1; i+= 0.1)
    {
        [self performSelectorInBackground:@selector(updateProgress:) withObject:[NSNumber numberWithFloat:i]];
        sleep(1000);
    }
    [workerPool release];
}

- (void)updateProgress:(NSNumber*)number
{
    NSLog("Progress is now: %@", number);
    [progressView setProgress:[number floatValue]];
}
+2
source

.

0

All Articles