IPhone development-UIWebView disable automatic detection data

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.