【问题标题】:How to navigate next tab while first tab view in process?如何在处理第一个选项卡视图时导航下一个选项卡?
【发布时间】:2023-04-07 22:52:01
【问题描述】:

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

现在第二个选项卡无法工作,而第一个选项卡视图正在处理中。我使用了 PerformSelectorInBackground 但它对我没有帮助??有谁能帮帮我吗????

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

Yuva.M

【问题讨论】:

    标签: uinavigationcontroller tabbar


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-15
      • 1970-01-01
      • 2013-12-19
      • 2020-12-13
      • 1970-01-01
      • 2017-05-06
      • 2014-07-28
      • 1970-01-01
      相关资源
      最近更新 更多