How can I close UIWebView after submitting form in the view? - ios

I have a UIWebView that displays a webpage including a feedback form. I want to remove this UIWebView after I submit the form in that view.
How can I do that?

You normally achieve this sort of thing by setting a delegate on the web view, to register for interesting callbacks.
Don't forget to nil the delegate before you dispose of the web view or you might experience a crash.

In the delegate for the UIWebView, within
webView:shouldStartLoadWithRequest:navigationType:
search for a the url triggered by the form submission. If it's present, set a flag value.
Then, in your delegate's webViewDidFinishLoad: method, if the flag is set, remove the webView.

Well You Have not made clear of your allocation of your webview or not familiar with your code .I guess you want to return to previous view from the UIWebView , in that case you can simply the push the viewcontroller containing the webview through a UINavigationController and get back to the view on back button or set a flag in webviewDidStartLoad and webViewDidFinishLoad and remove the view when the flag is set in DidFinish Part else please elaborate your problem.

Related

iOS how to remove existing UIWebView and reinitialise it

I have a UIWebView which load a page when the user navigates he can go to 7 levels I mean he can go to 7 different pages with different URL.
Now I want to go back to the first page directly instead of going back one by one.
I couldn't find any API in UIWebView to do this so I thought to loading the first page url again but UIWebView's cangoback will return true.
So I thought I will reinitialise the webview and load the URL
self.webview=[self.webview init];
as expect it loads the new url and UIWebView's cangoback returns false which is good.
but the problem is when I try to scroll the page down I can see the previous page behind it as background of scrollview.
Any ideas on how to fix the issue
You're leaving the old web view alive, but just calling it's init routine (which you shouldn't do more than once). Instead, call:
self.webview = [[UIWebView alloc] init];
That will give you a whole new web page like you originally started with, and will invoke ARC to dispose of the old one.

Xcode Display a loading view until the second view loads (on a segue show)

I have an app that switch views using a segue when a button is clicked.
The second view loads data from the internet and it can take a couple of seconds.
I would like to know how can i display a loading view/splash screen in the meantime so the view could finish the loading and the app wont appear like it's doing nothing.
Thanks!
Check this library SwiftSpinner. It serves the purpose of your needs. It's really brilliant.
Call the necessary function from the library in the viewDidLoad method of your ViewController which loads the data from the internet. Remove this view in DidFinishLoading method of the NSURLProtocol (It's an optional func declared in that class which detects when the request to that URL is complete). The documentation is given in that library itself.
Sounds like you're looking for an activity indicator. I've used the custom class posted https://stackoverflow.com/a/32661590/3516923 with success. Just a note of warning, in his class he blocks all input while the indicator is in view. If you want to make it so your users can back out before things finish you need to remove UIApplication.sharedApplication().beginIgnoringInteractionEvents() and UIApplication.sharedApplication().endIgnoringInteractionEvents() from the start and stop animating functions.
If what you want is really a splash screen, have a UIImageView underneath the view that you're loading. Set the image to your splash screen image. Set the loading view to hidden=YES before it's shown, then set hidden to NO after it finishes loading. You could even set the opacity of the frontmost view to give you a fading effect.
1.You need to find a kind of indicator, suck like an activity indicator or something else to show the loading UI to the user.
2.Set the user interaction unable, so that the user won`t touchup inside repeatedly.
3.Start the indicator, set the user interaction unable when you load the server data, and stop the indicator animation when you finish, hide the indicator, enabled the user interaction.

Any way to know before html content was shown in UIWebView

Is any possible ways that I would like to know before html content was shown in uiwebview.
coz when I called to some url, It will take a few seconds to complete the whole page loading. Before loading was completed, some of the content was already shown. I would like to know before that content was shown or before start showing.
UIWebView has a delegate protocol called UIWebViewDelegate. Two methods you should implement are – webViewDidStartLoad: notify monitoring object of when a site will about to load and – webView:shouldStartLoadWithRequest: notify when there a certain request like click, submit, back/forward etc are being made

UIWebView in IOS (Xamarin monotuch)

I am sure that this has been asked before but i am unable to get to a solution.
I have a UIWebView which is wrapped inside a UIView.
The web view loads HTML - Tapping on the HTML link results in certain action (Done. Detect the click in ShouldStartLoad and act accordingly).
Tapping anywhere else other than a link should result in another action - This is where i am having an issue. Just cant seem to get the tap gesture to work (on the UIWebView or the wrapper UIView)
Any clues?
Regards
Sid
Adding tap gesture recognizers is not an easy task due to the way it works internally (UIKit view hierarchy and WebKit view hierarchy).
I would suggest a much simpler solution. Add Hammer.js to your HTML (or inject it in webViewDidFinishLoad:), and on tap events, send a fake load request and catch like with links.
Hammer(el).on("tap", function() {
//Send fake request here.
});

Ensuring memory not leaking in UIWebView

I would like to know if I am using good memory management practise with UIWebView. My app makes extensive use of hundreds of local html files, which the user can get to at the end of a table hierarchy. The user can also swipe left and right for previous and next pages.
In viewDidLoad, I set everything up, such as background colour and gesture recognizers, and I add it to the view:
[self.view addSubview: self.myWebView];
Only in dealloc do I set the UIWebView's delegate to nil, and release it.
In viewWillAppear, I set the UIWebView's delegate to self, while in viewWillDisappear, I set the delegate to nil (as well as ask it to "stopLoading").
Each time I load a new document in, I use loadHTMLString:
[self.myWebView loadHTMLString:fullHTML baseURL:nil];
Is what I'm doing sufficient to keep the memory happy? Is this issue from two years ago still relevant?
Thank you!
What you have written should not leak memory. I don't know if the issue you linked to still happens, but I have not had problems with it in my use of UIWebView.

Resources