Query about UIWebview
HI am making a application in which the the user enter data into开发者_开发技巧 text field(url) and that url is opened in the webview below that .Now when the user clicks on any link in the webview that we have opened then can i get the address of the clicked url (the url which user clicked on the webview) as i need to update(display) that url into texfiled above , so that user can come to know which url is being opened.
you can use
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
delegate for your purpose.
like
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *requestedUrl = [request URL];
//use requestedURL methods
// like yourtextbox.text = [requestedUrl absoluteURL];
//don't forget to return YES :)
return YES;
}
Yes there is an undocumented method. See my answer in the post Show alert view when click on a link
Yes, UIWebView has some delegate methods which can help you with this:
Check this one
– webView:shouldStartLoadWithRequest:navigationType:
精彩评论