更新UI是必须回到主线程的,如果你是在网络请求的子线程中做操作,然后想更新UI的操作,那么需要把更新操作加入主队列,主队列的任务都是在主线程中执行的,这时需要用到GCD技术。
一般只需要这样写就可以
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),{ //需要长时间处理的代码 dispatch_async(dispatch_get_main_queue(),{ //需要主线程执行的代码 }) })参考: http://www.starming.com/index.php?v=index&view=24
其实只要用这个异步回调主线程就可以: