我尝试在通话后添加一些操作
- (void)parserDidStartDocument:(NSXMLParser *)parser {
//NSLog(@"found file and started parsing");
alertView = [[UIAlertView alloc] initWithTitle:@"Caricamento..."
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
[alertView addSubview:spinner];
[spinner startAnimating];
[alertView show];
}
但它会冻结应用程序一段时间,然后在完成 XML 解析后,加载 AlertView,ecc。与 UIRefreshControl 相同。我向下滑动 tableView,解析时应用程序冻结,我看不到微调器旋转。
任何想法?
编辑:在这里我第一次调用解析器:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSString * path = @"thexmlpath.xml";
if(!caricato)
[NSThread detachNewThreadSelector:@selector(parseXMLFileAtURL:) toTarget:self withObject:path];
//[self parseXMLFileAtURL:path];
caricato = YES;}
当我使用 RefreshControl 时,我在这里调用:
- (void)refreshControlRequest{
NSLog(@"refreshing...");
NSString * path = @"thexmlpath.xml";
[self performSelector:@selector(parseXMLFileAtURL:) withObject:path];}