Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView调用dispatch\u async(dispatch\u get\u main\u queue())时屏幕冻结_Ios_Swift_Dispatch Async - Fatal编程技术网

Ios UIView调用dispatch\u async(dispatch\u get\u main\u queue())时屏幕冻结

Ios UIView调用dispatch\u async(dispatch\u get\u main\u queue())时屏幕冻结,ios,swift,dispatch-async,Ios,Swift,Dispatch Async,我有一个需要显示的弹出窗口,直到所有图像上传到视图控制器上,我使用dispatch async方法在所有图像上传之前显示弹出窗口,并在图像显示时隐藏 但是调用dispatch\u async方法时,UIView屏幕冻结显示挂起弹出窗口,我在代码中哪里出错,或者实现这一点的最佳方法是什么 func imageIconTapped(gesture: UITapGestureRecognizer){ self.loadingPopUp = showPopUp(self, txt: “P

我有一个需要显示的弹出窗口,直到所有图像上传到视图控制器上,我使用dispatch async方法在所有图像上传之前显示弹出窗口,并在图像显示时隐藏

但是调用
dispatch\u async
方法时,
UIView
屏幕冻结显示挂起弹出窗口,我在代码中哪里出错,或者实现这一点的最佳方法是什么

func imageIconTapped(gesture: UITapGestureRecognizer){
        self.loadingPopUp = showPopUp(self, txt: “Processing..")
        self.navigationController!.view.addSubview(self.loadingPopUp!)

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {

           code to getting the image   // getting the images is time taking therefore it work in the background. 

            dispatch_async(dispatch_get_main_queue()) {                

        method to upload the images on the view controller and hide the popup.            
        }
函数“ImageIContaped”是已经在主线程上运行的UIKit方法,所以不需要向主队列分派代码


当您将代码从主线程分派到主队列时,主线程被阻塞。

我们无法知道为什么要花这么长时间,而不知道您正在对图像做什么。你可以发布你的代码的其余部分吗?实际上,我需要在图像未上传时显示弹出窗口,但当调用dispatch_async(dispatch_get_main_queue)时,弹出窗口显示但uiview冻结,下面是发送图像的方法。感谢你的快速回复,问题现在已经解决。