2

Possible Duplicate:
Disable links in UIWebView?

How can i disable the hyperlinks in a UIWebView and make it look like a normal text?

Community
  • 1
  • 1
makumar
  • 185
  • 2
  • 12

3 Answers3

8

Set this property of UIWebview

yourWebView.dataDetectorTypes = UIDataDetectorTypeNone;
ask4asif
  • 676
  • 4
  • 10
0

First set delegate to UIWebView when you want to use this method...

[self.webview setDelegate:sethere];

after that you can use the shouldStartLoadWithRequest: delegate method of UIWebView in which you add this type of logic to disable hyperlinks like bellow...

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

            NSURL *loadURL = [[request URL]retain];
            //change next line to whatever condition you need, e.g.
            //[[loadURL relativeString]  ....] contains a certain substring 
            //or starts with certain letter or ...
            if([[loadURL scheme] isEqualToString: @"file"])
            {
               [loadURL release]; 
            return TRUE;
            }
            [loadURL release];
            return FALSE;
  }

Also see the Reference from this webView:shouldStartLoadWithRequest:navigationType link

i hope this help you....

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • @Daij-Djan hey dude see the answer here i put condition with url scheme , if here condition tru then its return true otherwise return false dude.. :) – Paras Joshi Dec 19 '12 at 09:55
  • this line return true when content store the file which just allowed http:// or https:// so another hyperlinks not true here dude... for more info read about scheme of NSURL and also for UIWebView dude... – Paras Joshi Dec 19 '12 at 10:06
  • yes right here url or loadurl both works here dude.. just refer something and just test it and debug it dude.. :) – Paras Joshi Dec 19 '12 at 11:08
  • @Daij-Djan ok dude see the another answer about it http://stackoverflow.com/questions/1783074/disable-hyperlinks-in-uiwebview this is same like my code... – Paras Joshi Dec 19 '12 at 11:16
0

You can't change the content inside the UIWebView but you can disable the UIWebView responding to the links inside it by giving the UIWebView a delegate and implement the following in your code:

webView:shouldStartLoadWithRequest:navigationType: delegate method to return NO;

Siva Charan
  • 17,940
  • 9
  • 60
  • 95
Omar Freewan
  • 2,678
  • 4
  • 25
  • 49