【发布时间】:2016-06-27 11:39:09
【问题描述】:
我有一个弹出窗口需要在所有图像上传到视图控制器之前显示,我使用 dispatch-async 方法在所有图像上传之前显示弹出窗口并在图像显示时隐藏。
但是UIView 屏幕在调用dispatch_async 方法时冻结显示挂起弹出窗口,其中我的代码有误,或者实现此目的的最佳方法是什么。
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.
}
【问题讨论】:
-
如果没有看到您对图像做了什么,我们无法判断为什么需要这么长时间。您可以发布其余代码吗?
-
其实我需要在没有上传图片的时候显示弹窗,当调用dispatch_async(dispatch_get_main_queue)时弹出显示但是uiview冻结,这里是发送图片的方法。
-
感谢您的快速回复,现已解决。
标签: ios swift dispatch-async