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
Related
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".
I am attempting to create an application using the webview feature.
However, I need functionality that will allow me to segue between viewControllers without the webview taking time to present it self when the viewController loads.
This will require loading the webviews on the launch of the app. Any guidance on how to achieve this would be appreciated.
You can create a singleton to hold the UIWebview. In your AppDelegate, you can initialize your singleton and load content of your UIWebview.
Everytime you want to use it, just get this view from the singleton and add it to whereever you want.
I'm developing an iOS 7+ app that I need to offer the option of navigating to a certain web page to let the users to fill in a form there, and after that to come back to the app's view where the user was.
Is it possible to programmatically open Safari with a given url? If it is, I suppose that then there is no way to automatically redirect the user to your app from there... right? Is then a UIWebView the only option? Is it possible to navigate back or dismiss the view with the UIWebView without the need of user interaction?
Thanks
You can open links in Safari as detailed in this post How to launch safari and open URL from iOS app
I don't believe you can set a 'callback' and have it return to your app on completion, as you have no control over the user once they have exited your app's sandbox.
Opening the link in UIWebView would provide control, as you can utilize the UIWebView callbacks.
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!!
I've put together a very simple proof of concept app using a UIWebView (and a regular controller) to display a web page.
If the web page has external links then when clicked on the app will switch to the web app.
However there's no way to get back to my original app.
If I add a navigation controller will I get the ability to navigate back, or is there something else additionally that would be required?
(As well as launching web pages it will also be necessary to intercept custom links in the web page and perform some associated action, such as add a contact, in this situation I would also like to be able to navigate back to my app).
TIA
If your links open in Safari, the only way for your user to get back to your app is via the multitasking bar (or obviously quitting and tapping on your app icon)- there is no way to bring your app to the forefront programmatically from within another app.
I am confused though, if you have a UIWebView, the default behavior of clicking on links is to load the linked page in the same web view.
In any case, I think what you are wondering is how to intercept link clicks of a UIWebView so to do that, you should implement the delegate method:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
You can then test for clicked links via testing the navigationType property for UIWebViewNavigationTypeLinkClicked