سؤال

In my iOS app (a kind of flashCard application) I'm using a UIWebView and once the webview content loading is finished I need to perform some UI operations (changes).
I'm checking for this in webViewDidFinishLoad.
When a user taps on a card it will flip and different content is gets loaded. I am using the code below in this flipAction as well as in swipeAction (when user moves from one card to another) to check:

if (![[myWebView stringByEvaluatingJavaScriptFromString:@"document.readyState"] isEqualToString:@"complete"])
{
    [self performSelector:@selector(myCustomMethod:) withObject:self afterDelay:3.0];
}

Sometimes, not always, my UI will freeze on the above if condition and after that the UI will not respond further. The app must be manually killed and relaunched.

Do I need to call stringByEvaluatingJavaScriptFromString: method other than thread? or what may be the cause for this?

لا يوجد حل صحيح

نصائح أخرى

You can try background thread

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
    dispatch_async(queue, ^{
        // async operation
        // Call your method here

                dispatch_sync(dispatch_get_main_queue(), ^{
                    // Update UI here

                });
    });
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top