开发者

Obtaining hyperlink text from a web view

开发者 https://www.devze.com 2023-03-09 22:07 出处:网络
I am working on an assignment which requires me to open a HTML page in a webview in iPhone. I have a hyperlink which is shown as a string eg. \"sometext.fileextensiontype\". When this text开发者_如何学

I am working on an assignment which requires me to open a HTML page in a webview in iPhone. I have a hyperlink which is shown as a string eg. "sometext.fileextensiontype". When this text开发者_如何学运维 is clicked it redirects to a link eg. http:www.someweblink.com/uyewihwefkbnamsjdfb".

I am able to intercept the above URL but I want to read the hyperlink string i.e. sometext.fileextensiontype.


you require to confirm with the UIWebViewDelegate protocol and provide implementation to the below shouldStartLoadWithRequest

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request     navigationType:(UIWebViewNavigationType)navigationType {

      NSURL *myUrl = [request URL];
      NSString* urlString = [myUrl absoluteString];
      return YES;   
}
0

精彩评论

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