IOS implements its own web browser (canGoBack), ioscangoback

Source: Internet
Author: User

IOS implements its own web browser (canGoBack), ioscangoback
Create a UIWebView, define the forward, backward, and refresh buttons, and implement the UIWebViewDelegate method.
 
1. Back button event
 
-(IBAction) WebViewBack :( id) sender
 
{
 
If ([self. webview canGoBack]) {
 
[Self. webview goBack];
 
}
 
}
 
2. forward button event
 
-(IBAction) WebViewForward :( id) sender
 
{
 
If ([self. webview canGoForward])
 
[Self. webview goForward];
 
}
 
3. Refresh events
 
-(IBAction) WebViewRefresh :( id) sender
 
{
 
[Self. webview reload];
 
}
 
4. UIWebViewDelegate proxy method webViewDidFinishLoad
 
-(Void) webViewDidFinishLoad :( UIWebView *) webView1
 
{
 
NSString * title = [webView1 stringByEvaluatingJavaScriptFromString: @ "document. title"];
 
_ WebviewTitleLabel. text = title;
 
 
If (! [WebView1 canGoBack])
 
{
 
_ BtnWebviewGoBack. enabled = NO;
 
}
 
Else
 
{
 
_ BtnWebviewGoBack. enabled = YES;
 
}
 

 
If (! [WebView1 canGoForward])
 
{
 
_ BtnWebviewGoForward. enabled = NO;
 
}
 
Else
 
{
 
_ BtnWebviewGoForward. enabled = YES;
 
} // Determine whether forward or backward can be performed after webView is loaded to determine whether the backward key and forward key are available.
 
[_ Indicator stopRotateAnimation]; // stop rotating and refreshing the image
 
[_ LoadingView stopAnimating_LoadingView]; // stop the rotation of LoadingView
 
}
 
5. UIWebViewDelegate proxy method webViewDidStartLoad
 
-(Void) webViewDidStartLoad :( UIWebView *) webView
 
{
 
[_ Indicator startAnimating]; // starts rotating the refreshed image
 
[_ LoadingView startAnimating_LoadingView]; // starts the rotation of LoadingView
 
}

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.