IPhone development-UIWebView disable automatic detection data
Suppose you have a paragraph in the web page, part of the content in the middle is www.yesareno.com, UIWebview will automatically identify you as a http://www.yesareno.com, of course, in most cases is good, but there are some special circumstances, you don't recognize www.yesareno.com as a hyperlink (that is, if you click "no response", let alone this abnormal demand). How can you achieve this?
The source code of the webpage is as follows:
For help, go to www.yesareno.cn.
When you click www.yesareno.com on the webpage, The webview proxy is called:
(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {// Determine if we want the system to handle it.NSURL *url = request.URL;}
In this case, the url. schema is printed as http, which is the http added by webview. How can this problem be solved?
After reading the document, we found that webview has the property of Automatic Data Detection, that is, dataDetectorTypes, which includes
typedef NS_OPTIONS(NSUInteger, UIDataDetectorTypes) { UIDataDetectorTypePhoneNumber = 1 << 0, // Phone number detection UIDataDetectorTypeLink = 1 << 1, // URL detection #if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED UIDataDetectorTypeAddress = 1 << 2, // Street address detection UIDataDetectorTypeCalendarEvent = 1 << 3, // Event detection#endif UIDataDetectorTypeNone = 0, // No detection at all UIDataDetectorTypeAll = NSUIntegerMax // All types};You may have understood this. The simplest and most crude method is to set the dataDetectorTypes attribute to UIDataDetectorTypeNone.
Then run the program and click www.yesareno.com.
Tips.