首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone NSThread帮助

iPhone NSThread帮助
EN

Stack Overflow用户
提问于 2011-08-31 11:52:01
回答 2查看 223关注 0票数 0

我的线程出了点问题。目前,在线程完成之前,showInstructions打开的视图是禁用的。当线程在运行时,我如何使它具有交互性?

提前感谢!

代码语言:javascript
复制
 [self performSelectorOnMainThread:@selector(loadEverything) withObject:self waitUntilDone:YES];


    -(void)loadEverything {    
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

        [self performSelector:@selector(showInstructions)];
        [self performSelector:@selector(loadStats)];
        [self performSelector:@selector(animate_sideBTN)];
        [self performSelector:@selector(loadNIBs)];
        [self performSelector:@selector(incrementStats)];

        [NSThread detachNewThreadSelector:@selector(loadMap) toTarget:self withObject:nil];

        [[self.view viewWithTag: 123] removeFromSuperview];
        [pool drain];
        }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-31 15:49:20

请尝试在"performSelectorOnMainThread“中调用-(void)loadEverything,并从该调用NSThread detachNewThreadSelector:中调用不影响UI组件的操作和影响UI组件的self performSelector。

票数 1
EN

Stack Overflow用户

发布于 2011-08-31 14:04:43

我认为你应该学习一些GCD,并在一个代码块中做同样的代码。或者使用NSOperation…如果可能,避免使用线程。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7252377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档