开发者

Obtaining hyperlink text from a web view

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜