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-------");