Control of the UIWebView page (ii)

Source: Internet
Author: User

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)

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.