Search code examples
iphonemultithreadinguiwebviewgrand-central-dispatchuiwebviewdelegate

Loading images in webview blocking MAIN THREAD despite using multithreading


I have a html string which contains <img> tag with a image URL. I have loaded the html string as follows using grand central dispatch.. But my app stuck till the images fully loaded..help me please `

background=dispatch_queue_create("background_queues", NULL);

dispatch_async(background, ^{    

    [webView loadHTMLString:myDescriptionHTML baseURL:NULL]; });

dispatch_release(background);

Thanks in advance..


Solution

  • You can't make UIKit calls on a background thread. What's the point of this code? If you just call loadRequest: on the main thread, it won't block the UI while your image loads.