How iOS calls the WebView private API

Source: Internet
Author: User

-(void) Modifyua

{

ID webview = [uiwebviewinstance valueforkeypath:@ "_internal.browserview._webview"];

[WebView performselector: @selector (setcustomuseragent:) withobject:@ "mozilla/5.0 (Windows; U Windows NT 5.2) applewebkit/525.13 (khtml, like Gecko) chrome/0.2.149.27 safari/525.13 "];

}

This is an example of modifying the user Agent. To get WebView using the Key-value coding method

To get through Apple's review more securely, you can do this:

-(void) Modifyua

{

NSString *path = [@ "_internal.browser" stringbyappendingstring:@ "View._webview"];

ID webview = [g_webview Valueforkeypath:path];

NSString *selstring = [@ "Setcustom" stringbyappendingstring:@ "useragent:"];

Sel sel = nsselectorfromstring (selstring);

[WebView Performselector:sel withobject:@] mozilla/5.0 (Windows; U Windows NT 5.2) applewebkit/525.13 (khtml, like Gecko) chrome/0.2.149.27 safari/525.13 "];

}

Split the string and then the achievement OK

Source: http://blog.csdn.net/hursing

Related Article

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.