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

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

问题描述

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

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 发送到主线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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