Active Module Uiwebview_webview

Source: Internet
Author: User

Today we have to deal with WebView in the next few days:
Below are some of the webvview I've been looking for:
http://www.jianshu.com/p/3d7e4804033b
http://bxbxbai.gitcafe.io/2015/08/16/talk-about-bybird-app/
HTTP://WWW.JIANSHU.COM/P/CA496CB680FE first, let's take a look at UIWebView.

To load a local HTML page:

NSString *webpath = [[NSBundle mainbundle]pathforresource:@ ' Helloword ' oftype:@ ' HTML '];//get file path
nsurl *webURL = [ Nsurl fileurlwithpath:webpath];//set URL
nsurlrequest *urlrequest = [Nsurl requestrequestwithurl:weburl] via file path string ;//Set the related URL for the request submission
[self.webviewloadrequest:urlrequest];//Submit Request
1, request the network to obtain HTML

Our project requires a network request with parameters, return an HTML page

AF begin *************************
    //Increase these lines of code;
    Afsecuritypolicy *securitypolicy = [ Afsecuritypolicy alloc] init];
    [SecurityPolicy Setallowinvalidcertificates:yes];

    Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];
    Set up here;
    [manager Setsecuritypolicy:securitypolicy];
    Manager.responseserializer = [Afhttpresponseserializer serializer];

    [Manager post:activitylist

       parameters:params

          success:^ (afhttprequestoperation *operation,id Responseobject) {

              NSString *string = [[NSString alloc] Initwithdata:responseobject encoding:nsutf8stringencoding ];
              NSLog (@ "Success:%@", string);
          }
          failure:^ (afhttprequestoperation *operation,nserror *error) {
              NSLog (@ "failed:%@", error);
    AF over ********************
2, after the STR was shown on the WebView
[Self.activitywebview loadhtmlstring:string Baseurl:nil];
3, Interception URL processing

In Proxy Method-(BOOL) WebView: (UIWebView
) WebView Shouldstartloadwithrequest: (nsurlrequest) Request Navigationtype: (Uiwebviewnavigationtype) Navigationtype intercept processing Jump URL 4, JS call object-c function

JS Interactive
    Jscontext *context = [Self.webview  valueforkeypath:@ DocumentView.webView.mainFrame.javaScriptContext "];

Not logged in or token invalid, request login, Tologinbyapp is the agreed function name
    context[@ "Tologinbyapp"] = ^ () {
        NSLog (@) +++++++begin tologinbyapp+++++++ ");
        Nsarray *args = [Jscontext currentarguments];
        For (Jsvalue *jsval in args) {
            NSLog (@ "tologinbyapp:%@", JsVal);
        }
        Jsvalue *this = [Jscontext currentthis];
        NSLog (@ "Tologinbyapp--this:%@", this);
        NSLog (@ "-------end Tologinbyapp-------");

    

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.