1

I have a popup which need to be show until all the images are uploaded on the view controller, I use dispatch-async method to show the popup before all the images are uploaded and hide as the images display.

But the UIView screen freezes displaying hang popup on calling dispatch_async method where I was wrong in the code or whats the best way to achieve this.

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.            
        }
Bhadresh Mulsaniya
  • 2,610
  • 1
  • 12
  • 25
fmashkoor
  • 113
  • 1
  • 2
  • 6
  • We can't tell why it's taking so long, without seeing what you're doing with the image. Can you post the rest of your code? – Sander Saelmans Jun 27 '16 at 11:47
  • Actually i need to show popup when images are not uploaded, popup show but uiview freezes when dispatch_async(dispatch_get_main_queue) is call and here is the method to send the images. – fmashkoor Jun 27 '16 at 11:50
  • Thankyou for your quick reply, its solved now. – fmashkoor Jun 27 '16 at 12:15

1 Answers1

-1

The function "imageIconTapped" is UIKit method which is already run on main thread.So no need to dispatch code to main queue.

Main thread is block when you dispatch code from main thread to main queue.

Raj Aggrawal
  • 761
  • 1
  • 6
  • 21