gpt4 book ai didi

ios - NSXMLParser parserDidStartDocument 卡住应用程序

转载 作者:行者123 更新时间:2023-11-29 04:15:10 24 4
gpt4 key购买 nike

我尝试在调用后添加一些操作

- (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];}

最佳答案

希望这对你有帮助

- (void)parserDidStartDocument:(NSXMLParser *)parser {
//NSLog(@"found file and started parsing");
dispatch_queue_t queue = dispatch_get_main_queue();
dispatch_async(queue, ^{
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];
});
dispatch_release(queue);


}

关于ios - NSXMLParser parserDidStartDocument 卡住应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13821981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com