Search code examples
uinavigationcontrollertabbar

How to navigate next tab while first tab view in process?


I have 4 tabs in UITabBarcontroller. My problem is i need to navigate to next tab by user click while first tab process in on going?? how to run the process on background??

Now second tab not working while the first tab view in process. I used PerformSelectorInBackground but it's not help me?? Can any one help me Please????

Am poor in english, can you understand my problem?

Yuva.M


Solution

  • Run your heavy process with NSThread.

    Snippet from here:

    - (IBAction) startThreadButtonPressed:(UIButton *)sender {
    
        [NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil];
    
    }
    
    - (void)startTheBackgroundJob {
    
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        // wait for 3 seconds before starting the thread, you don't have to do that. This is just an example how to stop the NSThread for some time
        [NSThread sleepForTimeInterval:3];
        [self performSelectorOnMainThread:@selector(makeMyProgressBarMoving) withObject:nil waitUntilDone:NO];
        [pool release];
    
    }
    
    - (void)makeMyProgressBarMoving {
    
        float actual = [threadProgressView progress];
        if (actual < 1) {
            threadProgressView.progress = actual + 0.01;
            [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];
        }
    
    }