2016-06-27 2 views
1

모든 이미지가 뷰 컨트롤러에 업로드 될 때까지 표시해야하는 팝업이 있습니다. 모든 이미지가 업로드되기 전에 dispatch-async 메서드를 사용하여 팝업을 표시합니다. 이미지 표시로 숨 깁니다.dispatch_async (dispatch_get_main_queue())를 호출 할 때 UIView 화면 고정

그러나 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.    
     } 
+0

이미지로 수행하는 작업을 보지 않고 오랜 시간이 걸리는 이유를 알 수 없습니다. 나머지 코드를 게시 할 수 있습니까? –

+0

실제로 이미지가 업로드되지 않았을 때 팝업을 표시해야하지만, dispatch_async (dispatch_get_main_queue)가 호출 될 때 uiview가 멈추고 여기에 이미지를 보내는 방법이 있습니다. – fmashkoor

+0

답장을 보내 주셔서 감사합니다. – fmashkoor

답변

-1

"imageIconTapped"기능은 이미 메인 스레드에서 실행되는 UIKit 메소드입니다. 메인 대기열에 코드를 디스패치 할 필요가 없습니다.

주 스레드에서 주 큐로 코드를 발송할 때 주 스레드는 블록입니다.

관련 문제