ios – UITableView第一次没有显示,只有在滚动一点时

ios – UITableView第一次没有显示,只有在滚动一点时,第1张

概述我有一个UITableViewController,它从NSURLConnection加载数据: NSURL *url = [NSURL URLWithString:@"http://url.now"];NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCa 我有一个UItableVIEwController,它从NSURLConnection加载数据:

NSURL *url = [NSURL URLWithString:@"http://url.Now"];NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];NSOperationQueue *queue = [[NSOperationQueue alloc] init];[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response,NSData *data,NSError *error){    if ([data length] > 0 && error == nil){        NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];        [parser setDelegate:self];        [parser parse];    }    else if (error != nil){        UIAlertVIEw* alertVIEw = [[UIAlertVIEw alloc] initWithTitle:@"No internet connection" message:@"Content." delegate:self cancelbuttonTitle:@"OK" otherbuttonTitles:nil];        [alertVIEw performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:true];    }}];

解析结束时,将调用reloaddata方法.但是当加载应用程序时,UItableVIEw的内容不会显示.当我滚动一下时,它会立即显示出来.重新加载没问题.

怎么解决这个问题?

解决方法 解决了它.将tableVIEw reloadData更改为:

dispatch_async(dispatch_get_main_queue(),^{        [self.tableVIEw reloadData]; });

它就像一个魅力.感谢所有的答案和评论.

总结

以上是内存溢出为你收集整理的ios – UITableView第一次没有显示,只有在滚动一点时全部内容,希望文章能够帮你解决ios – UITableView第一次没有显示,只有在滚动一点时所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1076851.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存