【问题标题】: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];
}
}