我从Facebook获取数据,在获取数据期间,需要几毫秒或一秒钟。我希望保持完整,直到获取数据。
如何为此编写代码?
答案 0 :(得分:1)
- (void)viewDidLoad
{
[self performSelectorInBackground:@selector(startFatching) withObject:nil];
[super viewDidLoad];
}
- (void) startFatching
{
[self performSelectorOnMainThread:@selector(startIndicator) withObject:nil waitUntilDone:NO];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// your code
[self performSelectorOnMainThread:@selector(stopIndicator) withObject:nil waitUntilDone:NO];
[pool release];
}
- (void) startIndicator
{
av.hidesWhenStopped = YES;
[av startAnimating];
}
- (void) stoprIndicator
{
[av stopAnimating];
}
希望这会给你一些想法