2017-06-13 78 views
0

我不得不打电话来计算MainThread上的一些东西。当计算过程运行时,我可以调用UIProgressView来更新UI。
UIProgressView更新后台线程

当我就叫更新功能,它的工作,但更新最后

UI我使用performSelectorInBackground调用更新功能,它的做工精细

为什么要用performSelectorInBackground可以工作

click here to show GIF

我已经看到了这What's happen if control UI by performSelectorInBackground?,但它无法解释为什么performSelectorInBackground工作。

示例代码
https://github.com/g78101/progressViewTest

回答

0

我找到一些soultion

From the doc
[MyObj中performSelectorInBackground:@selector(doSomething的)withObject:无];
调用此方法的效果是一样的,如果你称为detachNewThreadSelector:toTarget:withObject:的方法NSThread与当前对象,选择器,和作为参数的参数对象。

BackgroundThread只是更改UI值,更新UI在mainThread上运行。

只是NSThrad可以工作

我想原因是NSThrad的框架比GCDS

简单