我有一个 UIActivityIndicator 应该循环直到加载 PDF 文件。
我不明白为什么,但在加载 PDF 之前指示器消失了。我无法理解 PDF 文件是否太大(1.4 MB)、我的应用程序是否冻结或我在代码中写错了什么
-(void)startTheProcess {
act = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//coordinate act
[act setCenter:CGPointMake(320 / 2, 440 / 2)];
self.act.hidden = FALSE;
[self.view addSubview:act];
[act startAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = TRUE;
[NSThread detachNewThreadSelector:@selector(creaVista) toTarget:self withObject:nil];
}
- (void) creaVista{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSURL *url = [NSURL URLWithString:@"http://www.something.com/file.pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[pdfView loadRequest:request];
[pdfView setScalesPageToFit:YES];
[self performSelectorOnMainThread:@selector(processDone) withObject:nil waitUntilDone:NO];
[pool release];
}
-(void)processDone {
[act stopAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = FALSE;
}
如果我调试它,我可以很容易地看到调试器快速进入[act stopAnimating]
然后停止,但文件尚未加载:几秒钟后 PDF 出现。
你有什么提示吗?我是菜鸟,我认为我犯了一些愚蠢的错误......谢谢