iOS - 另一个线程需要将reloadData发送到mainthread [英] iOS - another thread needs to send reloadData to the mainthread

查看:123
本文介绍了iOS - 另一个线程需要将reloadData发送到mainthread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单独的线程创建一个UIView对象,将其插入UITableView的数据源,然后在UITableView上调用reloadData。但是,由于它是一个单独的线程,它不能直接调用reloadData,它需要让mainthread执行它...但是你怎么告诉mainthread呢?

I got a separate thread that creates a UIView object, inserts it into the UITableView's data source and then call reloadData on the UITableView. However, since it is a separate thread, it cannot call reloadData directly, it needs to make the mainthread do it... but how do you tell the mainthread to do it?

谢谢

推荐答案

[self.tableView performSelectorOnMainThread:@selector(reloadData)
                                 withObject:nil
                              waitUntilDone:NO];

这篇关于iOS - 另一个线程需要将reloadData发送到mainthread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆