我有一些基本的疑问,猜猜别人会帮我。performSelectorOnMainThread通知
请参考这个问题:Update ULabel immediately while downloading files
我一直在使用performSelectorOnMainThread
,这是调用另一大类的UpdateProgress方法,但标签没有更新尝试。
但现在我已经使用像
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateProgress" object:nil userInfo:nil];
通知,这似乎是调用方法,并且还更新的UILabel。尽管我的问题已解决,但我想知道为什么上述performSelectorOnMainThread
对我没有帮助?任何具体原因?
它应该工作。你能在这里发布一些代码吗?你必须从某个线程和选择器调用performSelectorOnMainThread我假设你正在调用像[someOtherClassObj updateProgress];并注意,你必须从主线程调用postNotificationName,所以我想知道你是如何调用它 – msk 2012-07-10 11:32:17
我倾向于使用[performSelectorOnMainThread ... waitUntilDone:NO];而不是“waitUntilDone:YES”;其中一条评论也提到了这一点。我注意到有时会设置为“waitUntilDone:YES”;导致界面不更新。您是否尝试将其设置为“否”而不是“是”? – Zhang 2012-07-10 11:38:20