iphone - update UI always on Main Thread?

匿名 (未验证) 提交于 2019-12-03 01:26:01

问题:

I know Apple said all UI-related operations should be carried out on main thread.

So my question is "all UI-related operations" really mean every possible UI-related operaton?

For example, I will addSubview ViewB to ViewA in a separate thread. Should I always use [ViewA performSelectorOnMaintThread:@selector(addSubview:)...... on the separate thread?

thanks

回答1:

Yes.

It will crash otherwise.



回答2:

Yes, You should deal with all about UI in the main-thread. If you are under MFC, you should be in the same manner.



回答3:

Grand Central Dispatch does things in background threads (for example this line: dispatch_async(dispatch_get_main_queue(), myBlock);) and no crash at all. And i do a lot of things on myBlock()



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!