I am loading contents of HTML from UIWebview using stringByEvaluatingJavaScriptFromString: .Issue faced is while loading content from search engine of google website.For example I am searching 'bottle' in google website loaded in UIWebview it gives me the content of HTML of the bottles first time loaded, again I will go to fetch the HTML content when user scrolls down in UIWebview, There is a brief pause after calling the javascript causing other elements on the screen to hiccup for a moment.
Placing the javascript call in a function called in the background with self performSelectorInBackground breaks the application. Is there a safe way to call run this on a background thread or otherwise prevent the interface from pausing?
The "hiccup" is being caused because UIWebView's stringByEvaluatingJavaScriptFromString is running on the same thread, so it's blocking the UI.
Use WKWebView instead. It allows you to call evaluateJavaScript, where you provide a completion handler so that the JS call will be done on a separate thread and call the completion handler when it's ready, thus avoiding the "hiccup".
Related
UWP Webview I am using it in C#/xaml app, to load websites, it has stop() method to halt the content loading but when I want to resume content loading, after it being stopped, how can I do that? for example, I have several webviews on same page, and at start I halt all of them for good performance, but then according to user commands I want to resume their content loading, and then if I want to stop again I can stop, also does stop method means that it pauses the content load? or stops it completely? so that next time we have to navigate again?
Stop is like the browser "Stop" button. It halts all content download and is not resumable.
You'll need to reload/refresh the page that you want to "resume." Depending on the web page, some of the content maybe cached locally already so to the user it may appear as if it loads more quickly.
I have a UITextField, which checks a password and then my app loads data from a remote server. While this is happening I would like a progress view to display the progress of the download. My issue is that the UITextField seems to lock up the display until it returns and therefore I cannot update the progress view on the main thread. I also would like an answer without GCD or any other kind of threading as I am using core data and that would probably overcomplicate the app. Is there a way to have the UITextField not lock up the view so that I can update my progressView on the main thread?
If your app is loading data from a remote server, then you will have to use multi-threading(GCD, etc). Otherwise it just locks up the main thread till the download is finished which makes your app unresponsive.
To keep it simple, use GCD to fetch data(raw NSData) and give it to the main thread. Do all your processing on the main thread(core data, etc) as usual.
EDIT: One more thing, it is not the textfield locking up your UI, it is the download. So I don't think you can do anything other than multi-threading to help you here.
I'm doing now an iPhone App that encapsulate a web Site inside a UIWebView, the first request is made by the iphone app and it activate the "webViewDidFinishLoad" delegate, but when i press on one of the buttons in the web application inside the UIWebView this delegate is not working, do i need to do anything more in the ViewController or in the Html?
I Think i understand the specific problem: the next calls from the UIWebView are AJAX calls and it does not monitored by the webViewDidFinishLoad, i need some help, anyone know how to handle AJAC calls from UIWebView?
Thanks
Shimon
The right way to do it is to add UIGestureRecognizer to the UIWebView, and in the handler read the UIWebView string, then you can see the AJAX Updates done after the UIWebView was loaded for the first time' solved my problem
So I am trying to display an animated loading view (custom built) that will continue to animate while making a synchronous request to a web service.
I am familiar with synchronous and asynchrous requests using NSURLConnections and delegates, but my problem is that I want to ensure that my thread WAITS for the request to finish BUT still animates my loading indicator.
Are there any suggestions as to what the best way to go about this is?
Doing this with a synchronous request is not the way to go -- if you want your app to "wait" for the request to finish, you just put whatever code you want to resume after the request finishes in the connectionDidFinishLoading: method. That way, your UI will not be stalled and you can animate your loading indicator.
I've been searching for something like this in SO and nothing came up. So i've decided to ask for the first time here.
I'm working on an iOS project. I have a UIWebView working fine with a NSURLRequest. But, when i load a URL with multiple asynchronous requests (i.e. wsj.com) like ads and Facebook likes stuff; the scroll interaction of the web view becomes laggy and unresponsive.
I've been debbugging and that happens when the delegate method shouldStartRequest is executed (several times)
First shoot: using threads. Didn't work.
Second shoot: playing with web view properties of interaction.
Third shoot: tried to stop the unnecessary calls (my business rules doesn't need them) didn't work. Even if i kill them, the laggy effect remains.
The curious thing about all this is that Safari renders and works fine with the same URL.
I'm looking for thoughts, does anybody has some clue of what's happening here?
Thanks!!