JS Call oc Method UIWebView jump to another UIWebView

Source: Internet
Author: User
Tags uikit

1 //2 //BusinessListViewController.h3 //Loulilouwai4 //5 //Created by Jouhu on 15/7/31.6 //Copyright (c) 2015 Jouhu. All rights reserved.7 //8 9 #import<UIKit/UIKit.h>Ten  One @interfaceBusinesslistviewcontroller:uiviewcontroller A@property (Strong, nonatomic) NSString *urlstring; - //@property (Strong, nonatomic) NSString *titlestring; -  the @end
1 //2 //BUSINESSLISTVIEWCONTROLLER.M3 //Loulilouwai4 //5 //Created by Jouhu on 15/7/31.6 //Copyright (c) 2015 Jouhu. All rights reserved.7 //8 9 #import "BusinessListViewController.h"Ten #import "BusinessList2ViewController.h" One #import "MBProgressHUD.h" A  - @interfaceBusinesslistviewcontroller () <UIWebViewDelegate> -@property (Weak, nonatomic) iboutlet UIWebView *WebView; the @end -  - @implementationBusinesslistviewcontroller -  +- (void) Viewdidload { - [Super Viewdidload]; +     //Do any additional setup after loading the view from its nib. ASelf.automaticallyadjustsscrollviewinsets =NO; atSelf.edgesforextendedlayout =Uirectedgenone; -      -Uibarbuttonitem *backbarbuttonitem =[[Uibarbuttonitem alloc] init]; -Backbarbuttonitem.title =@"" ; -Self.navigationItem.backBarButtonItem =Backbarbuttonitem; -      inSelf.webview.Delegate=Self ; -      toNsurl *url =[Nsurl URLWithString:self.urlString]; +Nsurlrequest *urlrequest =[Nsurlrequest Requestwithurl:url]; - [Self.webview loadrequest:urlrequest]; the } *  $- (void) Viewwillappear: (BOOL) AnimatedPanax Notoginseng { - [Super viewwillappear:animated]; the      + //self.navigationItem.title = self.titlestring; A      the //Nsurl *url = [Nsurl URLWithString:self.urlString]; + //nsurlrequest *urlrequest = [Nsurlrequest requestwithurl:url]; - //[Self.webview loadrequest:urlrequest]; $ } $  - //-(void) Viewdiddisappear: (BOOL) Animated - //{ the //    //Clear Cache - //[Self.webview loadhtmlstring:@ "" Baseurl:nil];Wuyi //} the  --(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (Nsurlrequest *Request Navigationtype: (uiwebviewnavigationtype) Navigationtype Wu { -NSString *urlstring =[[Request URL] absolutestring]; AboutURLString =[URLString stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]; $NSLog (@"url1string=%@", urlstring); -      - //if ([urlstring isequaltostring:@ "About:blank"]) { - //return NO; A //    } +      theNsarray *urlcomps = [urlstring componentsseparatedbystring:@"://"]; -      $     if([Urlcomps Count] && [[Urlcomps Objectatindex:0] Isequaltostring:@"Protocol"]) the     { theNsarray *arrfucnameandparameter = [(nsstring*) [Urlcomps objectatindex:1] Componentsseparatedbystring:@";"]; theNSString *funcstr = [Arrfucnameandparameter objectatindex:0]; the          -         if(1==[Arrfucnameandparameter Count]) in         { the             //No Parameters the             if([Funcstr isequaltostring:@"doFunc1"]) About             { the                 /*calling local function 1*/ theNSLog (@"doFunc1"); the             } +         } -         Else the         {Bayi             //with parameters. the             if([Funcstr isequaltostring:@"toactivity"]) the             { -NSLog (@"DOFUNC2"); -[Self toactivitywithurl:[arrfucnameandparameter objectatindex:1] Title:[arrfucnameandparameter Objectatindex:2] Share:[arrfucnameandparameter Objectatindex:3]]; the             } the         } the         returnNO; the     } -     returnTRUE; the } the  the- (void) Webviewdidstartload: (UIWebView *) WebView94 { the [Mbprogresshud ShowHUDAddedTo:self.view animated:yes]; the } the 98- (void) Webviewdidfinishload: (UIWebView *) WebView About { - [Mbprogresshud HideAllHUDsForView:self.view animated:yes];101 }102 103- (void) WebView: (UIWebView *) WebView didfailloadwitherror: (Nserror *) Error104 { the     if([error code]! =nsurlerrorcancelled) {106 [Mbprogresshud HideAllHUDsForView:self.view animated:yes];107Uialertview *alterview = [[Uialertview alloc] Initwithtitle:@""Message:[error Localizeddescription]Delegate: Nil Cancelbuttontitle:nil Otherbuttontitles:@"Good", nil];108 [Alterview show];109     } the }111  the- (void) Toactivitywithurl: (NSString *) urlstring title: (NSString *) titlestring share: (NSString *) sharestring113 { theBusinesslist2viewcontroller *businesslist2viewcontroller = [[Businesslist2viewcontroller alloc] InitWithNibName:@"Businesslist2viewcontroller"Bundle:[nsbundle Mainbundle]]; the [Businesslist2viewcontroller Sethidesbottombarwhenpushed:yes]; thebusinesslist2viewcontroller.urlstring = [NSString stringWithFormat:@"http://%@", urlstring];117BusinessList2ViewController.navigationItem.title =titlestring;118Businesslist2viewcontroller.sharestring =sharestring;119 [Self.navigationcontroller Pushviewcontroller:businesslist2viewcontroller animated:yes]; - }121 122- (void) didreceivememorywarning {123 [Super didreceivememorywarning];124     //Dispose of any resources the can be recreated. the }126 127 /* - #pragma mark-navigation129  the //In a storyboard-based application, you'll often want to do a little preparation before navigation131 -(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender { the //Get The new view controller using [Segue Destinationviewcontroller].133 //Pass The selected object to the new view controller.134 }135 */136 137 @end

JS Call oc Method UIWebView jump to another UIWebView

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.