我的线程出了点问题。目前,在线程完成之前,showInstructions打开的视图是禁用的。当线程在运行时,我如何使它具有交互性?
提前感谢!
[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];
}发布于 2011-08-31 15:49:20
请尝试在"performSelectorOnMainThread“中调用-(void)loadEverything,并从该调用NSThread detachNewThreadSelector:中调用不影响UI组件的操作和影响UI组件的self performSelector。
发布于 2011-08-31 14:04:43
我认为你应该学习一些GCD,并在一个代码块中做同样的代码。或者使用NSOperation…如果可能,避免使用线程。
https://stackoverflow.com/questions/7252377
复制相似问题