List of properties/methods for 1.UIWebView content control
The Loading property verifies that the current page is in the read -in
The CanGoForward property verifies that the GoForward method is operational and can be run as Yes;
The CanGoBack property confirms that the GoBack method is operational and can run as yes.
GoBack method to return to previous page
Goforword method to go to the next page
Reload method reads the current page again
Stoploading method aborts the current page's read-in
2.webViewController.h
@interface Webviewcontroller:uiviewcontroller<uiwebviewdelegate,uinavigationcontrollerdelegate, uinavigationbardelegate>{ UIWebView *_webview;} @property (Nonatomic,strong) Uibarbuttonitem *reloadbutton; @property (Nonatomic,strong) Uibarbuttonitem *stopButton; @property (Nonatomic,strong) Uibarbuttonitem *backbutton; @property (nonatomic,strong) Uibarbuttonitem *forwardbutton ; @end
WEBVIEWCONTROLLER.M
-(void) viewdidload{[Super Viewdidload]; Do any additional setup after loading the view. Self.navigationItem.title = @ "UIWebView test version"; _webview = [[UIWebView alloc]init]; _webview.delegate = self; _webview.frame = Self.view.frame; _webview.autoresizingmask = uiviewautoresizingflexibleheight| Uiviewautoresizingflexiblewidth; _webview.scalespagetofit = YES; [Self.view Addsubview:_webview]; The Add button _reloadbutton = [[Uibarbuttonitem] Alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemrefresh target: Self action: @selector (Reloaddidpush)]; _stopbutton = [[Uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemstop target:self Action: @ Selector (Stopdidpush)]; _backbutton = [[Uibarbuttonitem alloc]initwithtitle:@ "Back" style:uibarbuttonitemstylebordered target:self action:@ Selector (Backdidpush)]; _forwardbutton = [[Uibarbuttonitem alloc]initwithtitle:@ "Forward" style:uibarbuttonitemstylebordered target:self Action: @selector (ForwaRddidpush)]; Nsarray *buttons = [Nsarray Arraywithobjects:_backbutton,_forwardbutton,_reloadbutton,_stopbutton, Nil]; [Self settoolbaritems:buttons animated:yes]; [Self.navigationcontroller Settoolbarhidden:no Animated:yes]; }-(void) reloaddidpush{[_webview reload];//read again page}-(void) stopdidpush{if (_webview.loading) {[_webview Stoplo ading];//read-in Stop}}-(void) backdidpush{if (_webview.cangoback) {[_webview goback];//return to previous screen}}-(void) forw arddidpush{if (_webview.cangoforward) {[_webview goforward];//go to Next page}}-(void) updatecontrolenabled{ Unified Update indicates button state [uiapplication sharedapplication].networkactivityindicatorvisible = _webview.loading; _stopbutton.enabled = _webview.loading; _backbutton.enabled = _webview.cangoback; _forwardbutton.enabled = _webview.cangoforward; }-(void) Viewdidappear: (BOOL) animated{//Screen display results after reading into the Web page screen [super viewdidappear:animated]; Nsurlrequest *request = [Nsurlrequest requestwithurl:[nsURL urlwithstring:@ "http://www.baidu.com"]; [_webview Loadrequest:request]; [Self updatecontrolenabled];} -(void) Viewwilldisappear: (BOOL) animated{//The active indicator of the state when the picture is off is set to off [Super viewwilldisappear:animated]; [UIApplication sharedapplication].networkactivityindicatorvisible = NO;} -(void) Webviewdidstartload: (UIWebView *) webview{[self updatecontrolenabled];} -(void) Webviewdidfinishload: (UIWebView *) webview{[self updatecontrolenabled];} -(void) WebView: (UIWebView *) WebView didfailloadwitherror: (Nserror *) error{[self updatecontrolenabled];}
Control of the UIWebView page (ii)