iphone - update UI always on Main Thread?

2020-02-16 04:47发布

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

3条回答
该账号已被封号
2楼-- · 2020-02-16 05:17

Yes.

It will crash otherwise.

查看更多
家丑人穷心不美
3楼-- · 2020-02-16 05:21

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

查看更多
你好瞎i
4楼-- · 2020-02-16 05:36

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()

查看更多
登录 后发表回答