开发者

Query about UIWebview

开发者 https://www.devze.com 2023-03-18 14:05 出处:网络
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 th

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:
0

精彩评论

暂无评论...
验证码 换一张
取 消