I have create an IOS app.
The app has MainViewController that will present/dismiss Modal view from webViewController
nib file(contains NavBar and UIWebView). I want to inject my javascript functions in every web pages that loaded by the UIWebView and those functions will be call in webpages that means all functions had to finish load before pages finish load.
I try many ways but it seem like when the ModalView present again(it’s work fine at first present).The page doesn’t know my injected function.
So my question is:
- Where should i inject my javascript if the UIWebView load request when the ModalView present? Before loadRequest? didStartLoad? didFinishLoad?
- What should i do with UIWebView when dismiss the ModalView? load the about:blank request?
Thanks for reading and any help/suggestion. 🙂
In
webViewDidFinishLoad:. You cannot callstringByEvaluatingJavaScriptFromString:until this point. There is unfortunately no good way to get to this point without displaying the web view, which can lead sometimes to the view “flashing” if your JavaScript changes things too much. I sometimes wind up putting an extra view over the web view to hide it until afterwebViewDidFinishLoad:completes.Nothing. It should be released when the modal view is released.