如何在第一个标签视图进行过程中导航下一个标签?

时间:2011-05-09 10:30:31

标签: uinavigationcontroller tabbar

我在UITabBarcontroller中有4个标签。我的问题是我需要通过用户点击导航到下一个选项卡,而第一个选项卡进程正在进行中?如何在后台运行进程??

当第一个标签视图正在进行时,第二个标签不起作用。我使用了PerformSelectorInBackground,但它对我没有帮助?任何人都可以帮助我吗????

英语很差,你能理解我的问题吗?

Yuva.M

1 个答案:

答案 0 :(得分:0)

使用NSThread运行繁重的流程。

来自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];
    }

}
相关问题