Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView finished loading Event

Is it possible to start an event when an UIWebView (Iphone) has finished loading the URL.

How can I find out, the current URL of the UIWebView?

like image 952
Ploetzeneder Avatar asked Nov 02 '09 17:11

Ploetzeneder


3 Answers

Yes, that's possible. Use the UIWebViewDelegate protocol and implement the following method in your delegate:

- (void)webViewDidFinishLoad:(UIWebView *)webView

If you want the URL, you can get the last request using the property request:

webView.request.URL
like image 146
Pascal Avatar answered Oct 17 '22 05:10

Pascal


None of the found solutions worked for me.

Then I found this example which at least works much better than any other solution I found on Google/StackOverflow.

uiwebview-load-completion-tracker

like image 2
sabiland Avatar answered Oct 17 '22 05:10

sabiland


Very simple method:

Step 1: Set delegate UIWebViewDelegate in header file.

Step 2: Add following webViewDidFinishLoad method to get current URL of webview

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSLog(@"Current URL = %@",webView.request.URL);

    //-- Add further custom actions if needed 
}
like image 1
Rajesh Loganathan Avatar answered Oct 17 '22 04:10

Rajesh Loganathan