ios 中请求主线程刷新UI

 

复制代码
 1 if ([NSThread isMainThread])  
 2 {  
 3     [self.downloadMapBtn setImage:[UIImage imageNamed:@"download_map.png"] forState:UIControlStateNormal];  
 4     [self.downloadMapBtn setNeedsDisplay];  
 5 }  
 6 else  
 7 {  
 8     dispatch_sync(dispatch_get_main_queue(), ^{  
 9         //Update UI in UI thread here  
10         [self.downloadMapBtn setImage:[UIImage imageNamed:@"download_map.png"] forState:UIControlStateNormal];  
11         [self.downloadMapBtn setNeedsDisplay];  
14     });  
15 }
复制代码

 

posted on   codemaker313  阅读(2426)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示