如何在第一个选项卡视图正在进行时导航下一个选项卡?

发布于 2024-11-06 02:10:20 字数 219 浏览 3 评论 0原文

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

现在,当第一个选项卡视图正在处理时,第二个选项卡不起作用。我使用 PerformSelectorInBackground 但它对我没有帮助?任何人都可以帮助我吗????

我英语不好,你能理解我的问题吗?

尤瓦·M

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

濫情▎り 2024-11-13 02:10:20

使用 < 运行繁重的流程代码>NSThread

摘自此处< /a>:

- (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];
    }

}

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

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文